切入点:
form_obj.is_valid()defis_valid(self):"""Return True if the form has no errors, or False otherwise."""return self.is_bound andnot self.errors
# 如果is_valid要返回True的话,那么self.is_bound要为True self.errors要为False
self.is_bound = data isnotNoneor files isnotNone# 只要你传值了就一定是True@propertydeferrors(self):"""Return an ErrorDict for the data provided for the form."""if self._errors isNone:
self.full_clean()return self._errors
# forms组件所有的功能基本都出于该方法deffull_clean(self):"""
Clean all of self.data and populate self._errors and self.cleaned_data.
"""
self._errors = ErrorDict()ifnot self.is_bound:# Stop further processing.return
self.cleaned_data ={}# If the form is permitted to be empty, and none of the form data has# changed from the initial data, short circuit any validation.if self.empty_permitted andnot self.has_changed():return#
self._clean_fields()
self._clean_form()
self._post_clean()
初做python web django框架 note1.forms组件源码切入点: form_obj.is_valid() def is_valid(self): """Return True if the form has no errors, or False otherwise.""" return self.is_bound and not self.errors # 如果is_valid要返回True的话,那么self.is_bound要为True self.err