Opened 16 years ago

Closed 16 years ago

Last modified 12 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: dev
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

Description

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@…> 16 years ago.

Download all attachments as: .zip

Change History (6)

by Daniel Roseman <daniel@…>, 16 years ago

Attachment: mergedict.diff added

comment:1 by Matt McClanahan, 16 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Michael Radziej, 16 years ago

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 by Malcolm Tredinnick, 16 years ago

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 by Malcolm Tredinnick, 16 years ago

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 by Jacob, 12 years ago

milestone: 1.0

Milestone 1.0 deleted

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