Opened 17 years ago

Closed 17 years ago

#5830 closed (duplicate)

ModelChoiceField does not allow you to change the queryset on the widget after __init__ is called

Reported by: Øyvind Saltvik <oyvind@…> Owned by: nobody
Component: Uncategorized Version: newforms-admin
Severity: Keywords: modelchoicefield property
Cc: michael@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

ModelChoiceField.__init__ assigns the default queryset to self.widget.choices; then if you change field.queryset later it is too late, as it does not set self.widget.choices again.

This is easily done by making self.queryset a property()

Attachments (1)

modelchoicefield_queryset_as_property.diff (1.2 KB ) - added by Øyvind Saltvik <oyvind@…> 17 years ago.
queryset as property

Download all attachments as: .zip

Change History (3)

by Øyvind Saltvik <oyvind@…>, 17 years ago

queryset as property

comment:1 by miracle2k, 17 years ago

Cc: michael@… added

comment:2 by Gary Wilson, 17 years ago

Resolution: duplicate
Status: newclosed

dup of #4787.

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