#20859 closed Cleanup/optimization (fixed)
Example for Model.clean doesn't call parent method
Reported by: | Aymeric Augustin | Owned by: | jimmysong |
---|---|---|---|
Component: | Documentation | Version: | 1.5 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#overriding-the-clean-method warns that if one customizes the clean()
method for a model, one should call the parent method to maintain default validation.
https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.clean shows an example which doesn't call the parent method.
I think the example should be modified to take this best practice into account.
Change History (8)
comment:1 by , 11 years ago
Component: | Uncategorized → Documentation |
---|---|
Easy pickings: | set |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
comment:2 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 11 years ago
Has patch: | set |
---|
comment:5 by , 11 years ago
The warning refers to ModelForm.clean()
while the example is for Model.clean()
which actually does not require calling super
as it does nothing. That said, I think the patch does help clarify the example, so I'll merge it minus the super
call.
comment:6 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Changed the example in the documentation. Pull request here: https://github.com/django/django/pull/1434