Flask-Web-App-Tutorial
Flask-Web-App-Tutorial copied to clipboard
Adding a new field to last name
Traceback (most recent call last): File "C:\Users\hugotk\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 2548, in call return self.wsgi_app(environ, start_response) File "C:\Users\hugotk\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 2528, in wsgi_app response = self.handle_exception(e) File "C:\Users\hugotk\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 2525, in wsgi_app response = self.full_dispatch_request() File "C:\Users\hugotk\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 1822, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\hugotk\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 1820, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\hugotk\AppData\Local\Programs\Python\Python310\lib\site-packages\flask\app.py", line 1796, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File "c:\Users\hugotk\Documents\ASK_Investimentos\WebApp\website\auth.py", line 54, in sign_up elif len(last_name) < 2: TypeError: object of type 'NoneType' has no len()
i am having the same issue
@auth.route('/signup', methods=['GET', 'POST']) def signup(): if request.method == 'POST': email = request.form.get('email') first_name = request.form.get('firstName') password1 = request.form.get('password1') password2 = request.form.get('password2') user = User.query.filter_by(email=email).first() if user: flash('Email already exists.', category='error') elif len(email) < 4: flash('Email must be greater than 4 characters', category='error') elif len(first_name) < 2: flash('First name must be greater than 2 character', category='error') elif password1 != password2: flash('Error, password mismatch', category='error') elif len(password2) < 7: flash('Password must be more than 7 characters', category='error') else: new_user = User(email=email, first_name=first_name, password=generate_password_hash(password1, method='sha256')) db.session.add(new_user) db.session.commit() login_user(user, remember=True) flash('Account created!', category='success') return redirect(url_for('views.home'))
return render_template("signup.html", user=current_user)
Not sure where I went wrong, but getting this out put
line 53, in signup elif len(first_name) < 2: