From the course: Flask Essential Training
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Form creation
- [Instructor] Flask-WTF is an extension that simplifies working with web frameworks in Flask. It integrates WTForms with Flask and provides useful features like form validation and CSRF protection. Now, typically you'd install Flask-WTF using pip install flask-wtf command. For our project, just make sure it's listed in your requirements .txt. There are five steps to create a Form in Flask, starting with installing the Flask-WTF, to finding your form using a class. Flask-WTF and WTForms are used to manage the form fields and validation. And next we set up a route and finally create a form template. Let's look at an example. Let's create forms .py inside the starter folder for this lesson 5-1. And in this file, we'll define our form using a class. First, we'll start with a couple of imports. So the string field is a field for text input. It generates an HTML input element of type text. We use it to create the name field where users can enter their name. And the submit field is a field…