Python Learning (39)--django form component

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.