Register and Edit profile in a Flask App

From TRCCompSci - AQA Computer Science
Revision as of 13:07, 23 October 2019 by Admin (talk | contribs) (Create sign up form)
Jump to: navigation, search

Create sign up form

In your 'forms.py' file we need to create a form for the sign-up process. You should have created 'forms.py' when you created your login form. So add the following:

class SignUpForm(FlaskForm):
    username = StringField('Username', validators=[DataRequired()])
    password = PasswordField('Password', validators=[DataRequired()])
    confirm = PasswordField('Confirm Password', validators=[DataRequired()])
    email = StringField('Email', validators=[])
    DOB = DateField('DOB', format='%Y-%m-%d')
    MF = SelectField(u'Gender', choices=['M', 'F'])
    submit = SubmitField('Sign In')

Create sign up template

Create sign up route

Insert data into users table