Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#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 Tim Graham, 11 years ago

Component: UncategorizedDocumentation
Easy pickings: set
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

comment:2 by jimmysong, 11 years ago

Owner: changed from nobody to jimmysong
Status: newassigned

comment:3 by jimmysong, 11 years ago

Has patch: set

Changed the example in the documentation. Pull request here: https://github.com/django/django/pull/1434

comment:4 by jimmysong, 11 years ago

fixed the tab indent issue in pull request.

comment:5 by Tim Graham, 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 Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In 94d7fed7750322e8b80402c1e731bab6d4509f2e:

Fixed #20859 - Clarified Model.clean() example.

comment:7 by Tim Graham <timograham@…>, 11 years ago

In ea7bef318fd42411e3db057e888367ef52fb23c3:

[1.6.x] Fixed #20859 - Clarified Model.clean() example.

Backport of 94d7fed775 from master

comment:8 by Aymeric Augustin, 11 years ago

Oops, sorry for the bad report :|

Note: See TracTickets for help on using tickets.
Back to Top