Opened 8 years ago

Closed 8 years ago

#26905 closed Cleanup/optimization (fixed)

Add possibility to pass MultiValueDict-like objects as a form's data

Reported by: Marcin Nowak Owned by: nobody
Component: Forms Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

value_from_datadict() of django.forms.widgets.MultipleHiddenInput and django.forms.widgets.SelectMultiple are not based on duck typing but on a strict checking for MultiValueDict class.

Changing implementation to duck typing will make code more flexible and open doors for passing any dict-like and MultiValueDict-like objects as a form's data.

Forms data passed as MultiValueDict class should be slightly faster due to less type checkings, but this is not a goal itself.

The discussion I've started about this improvement is here: https://groups.google.com/d/msg/django-developers/v-pk2l0hxHk/Vn-hEjMjAwAJ

I'm attaching a patch proposal.

Attachments (1)

0001-Added-possibility-to-use-any-MultiValueDict-like-obj.patch (3.5 KB ) - added by Marcin Nowak 8 years ago.
Duck typing proposal for value_from_datadict()

Download all attachments as: .zip

Change History (4)

by Marcin Nowak, 8 years ago

Duck typing proposal for value_from_datadict()

comment:1 by Tim Graham, 8 years ago

Triage Stage: UnreviewedAccepted

Can you send a pull request with that patch?

comment:2 by Marcin Nowak, 8 years ago

Yes, here you are - https://github.com/django/django/pull/6932
(sorry for late reply)

comment:3 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: newclosed

In 74bb013:

Fixed #26905 -- Allowed using MultiValueDict-like objects as form data.

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