November 2015
Beginner to intermediate
840 pages
26h 30m
English
ModelForm ValidationOne of Django’s central gotchas revolves around misunderstanding validation in forms inheriting ModelForm.
Much like a regular Django form, a ModelForm runs all of the clean and validator methods associated with the form (which is why we keep clean_name() and clean_slug()). However, a ModelForm also uses model validation.
That’s right: models also provide validation! Models supply a full_clean() method, which is similar to the form’s is_valid() method. Model validation is very similar to form validation. The model starts by validating individual fields with validators and clean methods. The model itself may supply field-specific clean methods, just as the form does, and the model may also similarly supply ...
Read now
Unlock full access