Opened 12 years ago

Closed 12 years ago

#3821 closed (fixed)

[patch] newforms.fields ChoiceField & MultipleChoiceField should honor widget overrides in subclasses

Reported by: Max Derkachev <mderk@…> Owned by: Adrian Holovaty
Component: Forms Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


ChoiceField & MultipleChoiceField take a default widget argument in init, and it make impossible to override widget attribute on class level in subclasses. Instead of

class MyChoiceField(ChoiceField):
   widget = RadioSelect
foo = MyChoiceField(choices=(....))

one must call it with widget argument every time:

foo = MyChoiceField(choices=(....), widget=RadioSelect)

Attachments (1)

fields_choices.patch (1.1 KB) - added by Max Derkachev <mderk@…> 12 years ago.

Download all attachments as: .zip

Change History (4)

Changed 12 years ago by Max Derkachev <mderk@…>

Attachment: fields_choices.patch added

comment:1 Changed 12 years ago by Simon G. <dev@…>

Component: Uncategorizeddjango.newforms
Owner: changed from Jacob to Adrian Holovaty
Triage Stage: UnreviewedReady for checkin

comment:2 Changed 12 years ago by Gary Wilson <gary.wilson@…>

Max, in the future please create your diffs from the root of the django repository. This makes things a bit easier for anyone trying to use the patch. Thanks.

comment:3 Changed 12 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [5053]) Fixed #3821 -- Added a widget class attribute to ChoiceField and
MultipleChoiceField. This makes them consistent with other field classes and
make subclassing easier. This is a backwards compatible change. Thanks, Max

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