Flask Tutorial
About Lesson

In this Flask Tutorial we are going to learn how to create Error Message in Flask-WTF, in the previous lesson we have learned that how you can create flask forms using Flask-WTF, now let’s add some error message system for our flask forms.

 

 

So this is our form.py file, and in this file we have created our simple login form and you can see that we have added some ready validators from Flask-WTF that is InputRequired(). 

 

 

 

And this is our app.py file with our required view functions and you can see that we have also added our login view function in here. in this view function just by submitting of the form we are going to redirect the users to the Index page using redirect function.

 

 

 

This is our login.html file , basically in here we need to put our Flask-WTF validation errors. and you can use this code for adding validation errors. this is for username, you can add the same for password, just change the username to the password.

 

 

Our complete code for login.html will looks like this.

 

templates/login.html

 

 

 

There are the rest of files for the course.

 

templates/base.html

 

 

 

templates/index.html

 

 

templates/contact.html

 

 

 

templates/about.html

 

 

 

templates/500.html

 

 

templates/404.html

 

 

 

Run your flask project and now you can see that we have a nice validation message from Flask-WTF.

Flask Tutorial - Error Message in Flask-WTF
Flask Tutorial – Error Message in Flask-WTF

 

Thank you for visiting my website! If you enjoyed the free courses, please consider supporting my works on Patreon.
Exercise Files
No Attachment Found
No Attachment Found