Python3 development of the Advanced-django framework in the form of the Verification Method Is_valid () source code

Source: Internet
Author: User

Method of checking Form form is_valid ()

We found that there are only two method methods in this function, which finally returns TRUE or False.

Let's go in. Is_bound property, which determines whether the transmitted data is not empty and the upload file is not empty

Point in. Errors found that this is a method disguised as a property, using the built-in decorator properties,

Here is a simple logic to judge everyone to see, to determine whether there is an error message, no information on the implementation of Self.full_clean ()

Let's take a look at the execution also look at the returned self._errors, the discovery starts to be empty, after Self.full_clean () the Self._errors value may change

Let's see full_clean,self._errors. Gets the instantiated object of Errordict (),

Let's take a peek errordict:

Self.cleaned_data is defined as an empty dictionary, and there are self.empty_permitted and not self.has_changed (), we also take a peek

self.empty_permitted

Not self.has_changed () has a value of false, no value is true,

After reading the above section, let's look at the following self._clean_fields (), Self._clean_form ()

As we walk here, we find that the author of this feature has left a place to expand.

Custom Form validation rules:

Python3 development of the Advanced-django framework in the form of the Verification Method Is_valid () source code

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.