Opened 10 years ago

Closed 8 years ago

Last modified 5 years ago

#4046 closed (fixed)

ForeignKey's formfield does not respect limit_choices_to

Reported by: webograph <webograph@…> Owned by: Luke Plant
Component: Forms Version: master
Severity: Keywords:
Cc: django@… Triage Stage: Fixed on a branch
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

Description

ForeignKey's formfield() function, which returns the Field for a newforms.Form created by form_for_model or form_for_instance, does not filter the options by limit_choices_to.

i've attached a patch to fix that.

(i'd like to do a bit of advertising here for bug #2445 or #1891, whose target group should be roughly the same as for this bug)

Attachments (6)

formfield_patch.diff (995 bytes) - added by webograph <webograph@…> 10 years ago.
formfield_patch.2.diff (1.6 KB) - added by webograph <webograph@…> 10 years ago.
updated patch that also changes newforms' model.py to respect the limited choices in clean()
formfield_patch.3.diff (1.5 KB) - added by webograph <webograph@…> 10 years ago.
svn upped to 5281 (didn't merge cleanly any more), i18n'ed exception. no changes as suggested by paul 05/16/07 yet.
related.py.patch (1.7 KB) - added by Jan Rademaker <j.rademaker@…> 9 years ago.
Patch for ForeignKey, OneToOneField, ManyToManyField, no validation
4046.diff (1.7 KB) - added by James Bennett 9 years ago.
Patch for current trunk
4046.qsrf.diff (1.3 KB) - added by Jeff Anderson 9 years ago.
for svn trunk after qs-rf merge

Download all attachments as: .zip

Change History (20)

Changed 10 years ago by webograph <webograph@…>

Attachment: formfield_patch.diff added

Changed 10 years ago by webograph <webograph@…>

Attachment: formfield_patch.2.diff added

updated patch that also changes newforms' model.py to respect the limited choices in clean()

comment:1 Changed 10 years ago by Paul Lanier <planier@…>

This also needs to be fixed on the rest of the related fields in related.py (ManyToManyField for instance).

Changed 10 years ago by webograph <webograph@…>

Attachment: formfield_patch.3.diff added

svn upped to 5281 (didn't merge cleanly any more), i18n'ed exception. no changes as suggested by paul 05/16/07 yet.

comment:2 Changed 10 years ago by simon@…

Wondering how this will fit in with the newforms-admin branch. Is limit_choices_to on death row by any chance?

Changed 9 years ago by Jan Rademaker <j.rademaker@…>

Attachment: related.py.patch added

Patch for ForeignKey, OneToOneField, ManyToManyField, no validation

comment:3 Changed 9 years ago by Jan Rademaker <j.rademaker@…>

comment:4 Changed 9 years ago by anonymous

Cc: django@… added

comment:5 Changed 9 years ago by anonymous

Will this be fixed or should I stop using it?

Changed 9 years ago by James Bennett

Attachment: 4046.diff added

Patch for current trunk

comment:6 Changed 9 years ago by James Bennett

Triage Stage: UnreviewedReady for checkin

The most recent patch was mostly correct. I've updated it with a minor correction, so it should be good to go now.

comment:7 Changed 9 years ago by James Bennett

Needs tests: set
Triage Stage: Ready for checkinAccepted

(bumping status back until I come up with tests for this)

comment:8 Changed 9 years ago by Daniel Pope <dan@…>

Summary: ForeignKey's formfield does not respect limit_choicesForeignKey's formfield does not respect limit_choices_to

comment:9 Changed 9 years ago by Jeff Anderson

I've updated this to work with trunk after the qs-rf branch merge.

Changed 9 years ago by Jeff Anderson

Attachment: 4046.qsrf.diff added

for svn trunk after qs-rf merge

comment:10 Changed 8 years ago by Luke Plant

Owner: changed from nobody to Luke Plant

comment:11 Changed 8 years ago by Luke Plant

Resolution: fixed
Status: newclosed

(In [7733]) newforms-admin: Fixed #4046 - ForeignKey's formfield does not respect limit_choices_to. Thanks ubernostrum, programmerq

comment:12 Changed 8 years ago by Jeff Anderson

milestone: 1.0

comment:13 Changed 8 years ago by Jeff Anderson

Triage Stage: AcceptedFixed on a branch

I guess this is more incentive to switch to NFA.

comment:14 Changed 5 years ago by Jacob

milestone: 1.0

Milestone 1.0 deleted

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