[Django] #21894: Error in example code in django.forms.Form.clean()¶

18 views
Skip to first unread message

Django

unread,
Jan 29, 2014, 3:06:49 AM1/29/14
to django-...@googlegroups.com
#21894: Error in example code in django.forms.Form.clean()¶
-----------------------------------+--------------------
Reporter: richard.kellner@… | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------
In Documentation version: development explanation of Cleaning and
validating fields
(https://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-and-
validating-fields-that-depend-on-each-other) that depend on each other
there is and error. Code in the sample would thow an exeptoion: TypeError:
argument of type 'NoneType' is not iterable because function does not
return anything back. Documentation in 1.6 is correct and does not have
this error. To resolve add return statement at the end of both function in
example:

{{{
# Always return the full collection of cleaned data.
return cleaned_data
}}}

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

Django

unread,
Jan 29, 2014, 3:11:04 AM1/29/14
to django-...@googlegroups.com
#21894: Error in example code in django.forms.Form.clean()¶
-----------------------------------+--------------------------------------
Reporter: richard.kellner@… | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: master
Severity: Normal | Resolution: worksforme
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by bmispelon):

* status: new => closed
* needs_better_patch: => 0
* resolution: => worksforme
* needs_tests: => 0
* needs_docs: => 0


Comment:

Hi,

The documentation is correct: this is a new feature in the development
version of Django (soon-to-be 1.7), as described by the note under the
example:

> In previous versions of Django, form.clean() was required to return a
dictionary of cleaned_data. This method may still return a dictionary of
data to be used, but it’s no longer required.

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

Django

unread,
Oct 14, 2015, 10:07:09 AM10/14/15
to django-...@googlegroups.com
#21894: Error in example code in django.forms.Form.clean()¶
-----------------------------------+--------------------------------------

Reporter: richard.kellner@… | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by CarstenF):

* status: closed => new
* resolution: worksforme =>


Comment:

Replying to [comment:1 bmispelon]:


> Hi,
>
> The documentation is correct: this is a new feature in the development
version of Django (soon-to-be 1.7), as described by the note under the
example:
>
> > In previous versions of Django, form.clean() was required to return a
dictionary of cleaned_data. This method may still return a dictionary of
data to be used, but it’s no longer required.

This however (referring to
[https://docs.djangoproject.com/en/1.8/ref/forms/validation/#cleaning-and-
validating-fields-that-depend-on-each-other this example code]), is
inconsistent with the example code's statement
{{{
cleaned_data = super(ContactForm, self).clean()
}}}
about which a subsequent paragraph says:
> Note that the call to `super(ContactForm, self).clean()` in the example
code ensures that any validation logic in parent classes is maintained.

That is, if the `clean()` method of the parent class is coded like the
example code for the child, the example code won't work.

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

Django

unread,
Oct 17, 2015, 4:18:58 PM10/17/15
to django-...@googlegroups.com
#21894: Error in example code in django.forms.Form.clean()¶
-----------------------------------+--------------------------------------

Reporter: richard.kellner@… | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by timgraham):

* Attachment "21894.diff" added.

Django

unread,
Oct 17, 2015, 4:19:31 PM10/17/15
to django-...@googlegroups.com
#21894: Error in example code in django.forms.Form.clean()¶
-----------------------------------+------------------------------------

Reporter: richard.kellner@… | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by timgraham):

* has_patch: 0 => 1
* stage: Unreviewed => Accepted


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

Django

unread,
Oct 21, 2015, 1:53:44 PM10/21/15
to django-...@googlegroups.com
#21894: Error in example code in django.forms.Form.clean()¶
-----------------------------------+------------------------------------
Reporter: richard.kellner@… | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed

* resolution: => fixed


Comment:

In [changeset:"80855a4b3787bace050a8b4a2b80f79306e69812" 80855a4]:
{{{
#!CommitTicketReference repository=""
revision="80855a4b3787bace050a8b4a2b80f79306e69812"
Fixed #21894 -- Corrected a form.clean() example in case a superclass
doesn't return data.
}}}

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

Django

unread,
Oct 21, 2015, 1:54:13 PM10/21/15
to django-...@googlegroups.com
#21894: Error in example code in django.forms.Form.clean()¶
-----------------------------------+------------------------------------
Reporter: richard.kellner@… | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

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

In [changeset:"6861c2027da87cd9606cef8530e738613bb8c293" 6861c20]:
{{{
#!CommitTicketReference repository=""
revision="6861c2027da87cd9606cef8530e738613bb8c293"
[1.8.x] Fixed #21894 -- Corrected a form.clean() example in case a


superclass doesn't return data.

Backport of 80855a4b3787bace050a8b4a2b80f79306e69812 from master
}}}

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

Django

unread,
Oct 21, 2015, 1:54:14 PM10/21/15
to django-...@googlegroups.com
#21894: Error in example code in django.forms.Form.clean()¶
-----------------------------------+------------------------------------
Reporter: richard.kellner@… | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

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

In [changeset:"55ed23fd3e17c7743252a967a8f9957e038d35c4" 55ed23fd]:
{{{
#!CommitTicketReference repository=""
revision="55ed23fd3e17c7743252a967a8f9957e038d35c4"
[1.9.x] Fixed #21894 -- Corrected a form.clean() example in case a


superclass doesn't return data.

Backport of 80855a4b3787bace050a8b4a2b80f79306e69812 from master
}}}

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

Reply all
Reply to author
Forward
0 new messages