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