First, build a form
Suppose you want to create a simple form on your website to get the user's name. You need a template like this:
<formAction= "/your-name/"Method= "POST"> <label for= "Your_Name">Your Name:</label> <inputID= "Your_Name"type= "text"name= "Your_Name"> <inputtype= "Submit"value= "OK"></form>
This is a very simple form. In practice, a form might contain hundreds of dozens of of fields, most of which need to be pre-populated, and we expect the user to edit back and forth-submit several times to complete the operation.
We may need to do some validation on the browser side before the form is submitted. We might want to use very complex fields to allow users to do things like picking dates from a calendar, and so on.
this time, it's easy for Django to do most of the work for us.
form component:
1 when the form form is submitted, the data is wrong, and the previously entered data can still be retained on the returned page.
2 Check rule, return error message
Python Learning (39)--django form component