[Django] #20859: Example for Model.clean doesn't call parent method

5 views
Skip to first unread message

Django

unread,
Aug 4, 2013, 5:31:24 AM8/4/13
to django-...@googlegroups.com
#20859: Example for Model.clean doesn't call parent method
-----------------------------------------+------------------------
Reporter: aaugustin | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.5
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/20859>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 4, 2013, 6:08:04 AM8/4/13
to django-...@googlegroups.com
#20859: Example for Model.clean doesn't call parent method
--------------------------------------+------------------------------------
Reporter: aaugustin | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timo):

* type: Uncategorized => Cleanup/optimization
* component: Uncategorized => Documentation
* easy: 0 => 1
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/20859#comment:1>

Django

unread,
Aug 4, 2013, 11:27:15 AM8/4/13
to django-...@googlegroups.com
#20859: Example for Model.clean doesn't call parent method
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: jimmysong
Type: | Status: assigned
Cleanup/optimization | Version: 1.5
Component: Documentation | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by jimmysong):

* owner: nobody => jimmysong
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/20859#comment:2>

Django

unread,
Aug 4, 2013, 3:43:21 PM8/4/13
to django-...@googlegroups.com
#20859: Example for Model.clean doesn't call parent method
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: jimmysong
Type: | Status: assigned
Cleanup/optimization | Version: 1.5
Component: Documentation | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0

Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by jimmysong):

* has_patch: 0 => 1


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/20859#comment:3>

Django

unread,
Aug 4, 2013, 3:49:11 PM8/4/13
to django-...@googlegroups.com
#20859: Example for Model.clean doesn't call parent method
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: jimmysong
Type: | Status: assigned
Cleanup/optimization | Version: 1.5
Component: Documentation | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by jimmysong):

fixed the tab indent issue in pull request.

--
Ticket URL: <https://code.djangoproject.com/ticket/20859#comment:4>

Django

unread,
Aug 5, 2013, 8:44:25 AM8/5/13
to django-...@googlegroups.com
#20859: Example for Model.clean doesn't call parent method
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: jimmysong
Type: | Status: assigned
Cleanup/optimization | Version: 1.5
Component: Documentation | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by timo):

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/20859#comment:5>

Django

unread,
Aug 5, 2013, 9:06:31 AM8/5/13
to django-...@googlegroups.com
#20859: Example for Model.clean doesn't call parent method
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: jimmysong
Type: | Status: closed
Cleanup/optimization | Version: 1.5
Component: Documentation | Resolution: fixed

Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"94d7fed7750322e8b80402c1e731bab6d4509f2e"]:
{{{
#!CommitTicketReference repository=""
revision="94d7fed7750322e8b80402c1e731bab6d4509f2e"
Fixed #20859 - Clarified Model.clean() example.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/20859#comment:6>

Django

unread,
Aug 5, 2013, 9:07:10 AM8/5/13
to django-...@googlegroups.com
#20859: Example for Model.clean doesn't call parent method
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: jimmysong
Type: | Status: closed
Cleanup/optimization | Version: 1.5
Component: Documentation | Resolution: fixed
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"ea7bef318fd42411e3db057e888367ef52fb23c3"]:
{{{
#!CommitTicketReference repository=""
revision="ea7bef318fd42411e3db057e888367ef52fb23c3"
[1.6.x] Fixed #20859 - Clarified Model.clean() example.

Backport of 94d7fed775 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/20859#comment:7>

Django

unread,
Aug 5, 2013, 11:12:55 AM8/5/13
to django-...@googlegroups.com
#20859: Example for Model.clean doesn't call parent method
-------------------------------------+-------------------------------------
Reporter: aaugustin | Owner: jimmysong
Type: | Status: closed
Cleanup/optimization | Version: 1.5
Component: Documentation | Resolution: fixed
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by aaugustin):

Oops, sorry for the bad report :|

--
Ticket URL: <https://code.djangoproject.com/ticket/20859#comment:8>

Reply all
Reply to author
Forward
0 new messages