Code

Opened 6 years ago

Closed 6 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: UI/UX:

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@…> 6 years ago.
queryset as property

Download all attachments as: .zip

Change History (3)

Changed 6 years ago by Øyvind Saltvik <oyvind@…>

queryset as property

comment:1 Changed 6 years ago by miracle2k

  • Cc michael@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 6 years ago by gwilson

  • Resolution set to duplicate
  • Status changed from new to closed

dup of #4787.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.