Following the Flask Login manual , I am looking for the right library to include so that I can call the LoginForm() function.
Which library do I need to include that contains the LoginForm() part?
LoginForm
is a class inherit from FlaskForm
First, you need install some modules: pip install flask flask-login flask-wtf
There is a module (such as form.py
) with content:
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField
class LoginForm(FlaskForm):
username = StringField('Username')
password = PasswordField('Password')
submit = SubmitField('Submit')
This module contains form which be generated by flask_wtf
module. And import LoginForm in your script.
from form import LoginForm
File login.html
(in templates directory in current directory) will using flask-wtf to generate html code for LoginForm by using wtf.quick_form(form)
You can read example in this article to understand more detail or flask home page to understand structure of flask app
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.