Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#7195 closed (fixed)

MultipleChoice fields don't validate when using request.REQUEST

Reported by: Daniel Roseman <daniel@…> Owned by: nobody
Component: Forms Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no


MultipleChoice fields always give a validation error if you instantiate the form using data from request.REQUEST rather than request.POST.

This is because the SelectMultiple widget only uses the getlist() method if the data dictionary is a MultiValueDict, whereas request.REQUEST is a MergeDict.

Patch and tests attached.

Attachments (1)

mergedict.diff (2.2 KB) - added by Daniel Roseman <daniel@…> 11 years ago.

Download all attachments as: .zip

Change History (6)

Changed 11 years ago by Daniel Roseman <daniel@…>

Attachment: mergedict.diff added

comment:1 Changed 11 years ago by Matt McClanahan

Triage Stage: UnreviewedAccepted

comment:2 Changed 11 years ago by Michael Radziej

milestone: 1.0
Patch needs improvement: set

I have one objection about the patch: It always treats a MergeDict like a MultiValueDict. But a MergeDict does not need to be merging MultiValueDicts. If it merges normal dicts, the patch is not appropriate.

Anyway, this is a bug so ==> milestone 1.0

comment:3 Changed 11 years ago by Malcolm Tredinnick

I'm not really worried about people passing in a MergeDict of arbitrary dictionaries here. We don't need to publicly support every type of possible data structures, just the normal dictionary case and anything that Django might have to pass in internally. So this approach is fine.

comment:4 Changed 11 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [8525]) Fixed #7195 -- Fixed the validation of MultipleChoice fields so that they can
be populated from request.REQUEST. Based on a patch from Daniel Roseman.

comment:5 Changed 8 years ago by Jacob

milestone: 1.0

Milestone 1.0 deleted

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