Opened 8 years ago

Closed 7 years ago

Last modified 4 years ago

#4046 closed (fixed)

ForeignKey's formfield does not respect limit_choices_to

Reported by: webograph <webograph@…> Owned by: lukeplant
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@…> 8 years ago.
formfield_patch.2.diff (1.6 KB) - added by webograph <webograph@…> 8 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@…> 8 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@…> 8 years ago.
Patch for ForeignKey, OneToOneField, ManyToManyField, no validation
4046.diff (1.7 KB) - added by ubernostrum 8 years ago.
Patch for current trunk
4046.qsrf.diff (1.3 KB) - added by programmerq 7 years ago.
for svn trunk after qs-rf merge

Download all attachments as: .zip

Change History (20)

Changed 8 years ago by webograph <webograph@…>

Changed 8 years ago by webograph <webograph@…>

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

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

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

Changed 8 years ago by webograph <webograph@…>

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 8 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 8 years ago by Jan Rademaker <j.rademaker@…>

Patch for ForeignKey, OneToOneField, ManyToManyField, no validation

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

comment:4 Changed 8 years ago by anonymous

  • Cc django@… added

comment:5 Changed 8 years ago by anonymous

Will this be fixed or should I stop using it?

Changed 8 years ago by ubernostrum

Patch for current trunk

comment:6 Changed 8 years ago by ubernostrum

  • Triage Stage changed from Unreviewed to Ready 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 8 years ago by ubernostrum

  • Needs tests set
  • Triage Stage changed from Ready for checkin to Accepted

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

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

  • Summary changed from ForeignKey's formfield does not respect limit_choices to ForeignKey's formfield does not respect limit_choices_to

comment:9 Changed 7 years ago by programmerq

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

Changed 7 years ago by programmerq

for svn trunk after qs-rf merge

comment:10 Changed 7 years ago by lukeplant

  • Owner changed from nobody to lukeplant

comment:11 Changed 7 years ago by lukeplant

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

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

comment:12 Changed 7 years ago by programmerq

  • milestone set to 1.0

comment:13 Changed 7 years ago by programmerq

  • Triage Stage changed from Accepted to Fixed on a branch

I guess this is more incentive to switch to NFA.

comment:14 Changed 4 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

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