#21894 closed Bug (worksforme)

Error in example code in django.forms.Form.clean()¶

Reported by: richard.kellner@… Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


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

Change History (1)

comment:1 Changed 20 months ago by bmispelon

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed


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.

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