Django

Code

Ticket #5830 (closed: duplicate)

Opened 10 months ago

Last modified 10 months ago

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

Reported by: Øyvind Saltvik <oyvind@saltvik.no> Assigned to: nobody
Milestone: Component: Uncategorized
Version: newforms-admin Keywords: modelchoicefield property
Cc: michael@elsdoerfer.info Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

modelchoicefield_queryset_as_property.diff (1.2 kB) - added by Øyvind Saltvik <oyvind@saltvik.no> on 10/28/07 22:39:02.
queryset as property

Change History

10/28/07 22:39:02 changed by Øyvind Saltvik <oyvind@saltvik.no>

  • attachment modelchoicefield_queryset_as_property.diff added.

queryset as property

10/29/07 06:00:04 changed by miracle2k

  • cc set to michael@elsdoerfer.info.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

10/29/07 19:06:05 changed by gwilson

  • status changed from new to closed.
  • resolution set to duplicate.

dup of #4787.


Add/Change #5830 (ModelChoiceField does not allow you to change the queryset on the widget after __init__ is called)




Change Properties
Action