"Flask Web Development" Learning Note---chapter4 web Forms

Source: Internet
Author: User

1. We use the wrapper wtforms FLASK-WTF extension to handle form generation and validation.


2. Cross-site Request Forgery (CSRF) protection

Configuration config, ' Secret_key '


3. Form class definition

From FLASK.EXT.WTF import formfrom wtforms import Stringfield, submitfieldfrom wtforms.validators import Requiredclass Na Meform (Form):    name = stringfiled (' What's your name? ', validators=[required])    submit = submitfiled (' Submit ')



4. Standard fields

Stringfieldtextareafieldpasswordfieldhiddenfielddatefield            Text Field accepts a dattime.date value in a given Formatdatetimefield   Integerfielddecimalfieldfloatfieldbooleanfieldradiofieldselectfieldselectmultiplefieldfilefieldsubmitfieldformfieldfieldl Ist


5. Standard validators

Lying trough, this is a bit old, or see wtforms documents go.

Emailequalto    useful for password validation ipaddresslengthnumberrange   Verify that value is in a numeric range optionalrequired        field contains data regexp         Regular validation urlanyofnoneof



6.

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.