Opened 10 years ago

Closed 10 years ago

#23286 closed Cleanup/optimization (worksforme)

Add the necessary return value for Form#clean (in 1.6)

Reported by: jameydeorio Owned by: nobody
Component: Documentation Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The documentation for Form and field validation (https://docs.djangoproject.com/en/1.6/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other) says nothing about returning self.cleaned_data, without which you receive the obtuse "argument of type 'NoneType' is not iterable" along with an unhelpful stack trace, and you wind up on StackOverflow instead of the docs to solve the issue.

Change History (2)

comment:1 by Baptiste Mispelon, 10 years ago

Hi,

In the link you provided, the example code has these two lines at the bottom:

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

Is that not sufficient?

Note that if you're reading the documentation for 1.7 [1], these lines are gone because it's not necessary to return cleaned_data from Form.clean() anymore.
Was that the source of the confusion?

[1] https://docs.djangoproject.com/en/1.7/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other

comment:2 by Tim Graham, 10 years ago

Resolution: worksforme
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top