Flask WTF
wtf
- WTF stands for WT Forms.
- To provide the interactive user interface for the user.
- It is a built-in module of the flask which provides an alternative way of designing forms in the flask web applications.
Why WTF Useful ?
- The form elements are sent along with the request object from the client side to the server side. Server-Side script must recreate the form elements since there's no direct mapping between the client side form elements and therefore the variables to be used at the server side.
- There is no way to render the HTML form data at real time.
- The WT Forms may be a flexible, form rendering, and validation library wont to provide the interface.
Install Flask-WTF
- To use the WT forms, we need to install the flask-wtf library which can be installed using pip installer.
Standard Form Fields are listed:
SN | Form Field | Description |
---|---|---|
1 | BooleanField | It is used to represent the checkbox HTML form element. |
2 | DecimalField | It is used to represent the text field to display the numbers with decimals. |
3 | BooleanField | It is used to represent the checkbox HTML form element. |
4 | IntegerField | It is used to represent the text field to display the integer values. |
5 | RadioField | It is used to represent the radio button HTML form element. |
6 | selectField | It is used to represent the select form element. |
7 | TextAreaField | It is used to represent text area form element. |
8 | PasswordField | It is used to take the password as the form input from the user.. |
9 | SubmitField | It provides represents the <input type='submit' value='Submit'> html form element. |
Sample code
Here we will create a form using flask WTF module.
forms.py
formexample.py
contact.html
Success.html
Output
Registration
If you want to learn about Python Course , you can refer the following links Python Training in Chennai , Machine Learning Training in Chennai , Data Science Training in Chennai , Artificial Intelligence Training in Chennai