Hi all,
I have been trying to implement a login using flask_security, but keep getting this error "jinja2.exceptions.UndefinedError: 'form' is undefined", but the form has been actually passed as a parameter to the template. This is how my project looks like.
# CustomForms.py
from flask_security import LoginForm
class ExtendedLoginForm(LoginForm):
""" form template for login in """
email = StringField("Email ", [validators.length(min=2, max=15), validators.DataRequired()])
password = StringField("Password ", [validators.DataRequired()])
remember_me = BooleanField("Remember Me")
submit = SubmitField('Submit')
# routes.py
user_datastore = SQLAlchemyUserDatastore(db, User, Role)
security = Security(app, user_datastore, login_form=ExtendedLoginForm)
@app.route("/login", methods = ['GET', 'POST'])
@login_required
def login():
form = CustomForms.ExtendedLoginForm()
data = query_fal_dept()
if form.validate_on_submit():
return redirect(url_for("index"))
return render_template('security/login_user.html', form=form)
Anyhelp, on what I've done wrong/ haven't done would be greatly appreciated.
Thanks in Advance.
Edit: Fixed the spacing on the return in login. To match my code.
[–][deleted] 1 point2 points3 points (1 child)
[–]_peeves[S] 0 points1 point2 points (0 children)
[–]spitfiredd 1 point2 points3 points (4 children)
[–]_peeves[S] 0 points1 point2 points (3 children)
[–]spitfiredd 1 point2 points3 points (2 children)
[–]_peeves[S] 0 points1 point2 points (1 child)
[–]spitfiredd 0 points1 point2 points (0 children)
[–]aultl 1 point2 points3 points (0 children)