Code

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#6399 closed (duplicate)

ModelForm fields for RelatedFields should use limit_choices_to

Reported by: Daniel Pope <dan@…> Owned by: nobody
Component: Forms Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The limit_choices_to property for ForeignKey, ManyToManyField etc currently only affects the admin page for the model. It does not currently limit choices for the ModelChoiceField/MultipleModelChoiceField when using ModelForm.

I find this slightly misleading to read, and inconvenient to use, as I would like to use limit_choices_to to place a constraint on the data across the board, not just in the admin screen.

Attachments (0)

Change History (3)

comment:1 Changed 6 years ago by brosner

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #4096. The reason why this is the case is due to a bug in newforms where limit_choices_to is not respected by the ForeignKey formfield method. The admin works because it is currently using oldforms.

comment:2 Changed 6 years ago by brosner

  • Component changed from Database wrapper to django.newforms

Opps, I meant to reference #4046 and not #4096. ;)

comment:3 Changed 6 years ago by Daniel Pope <dan@…>

I didn't spot that because I searched Trac for 'limit_choices_to'.

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.