Opened 10 years ago

Closed 9 years ago

#4207 closed (duplicate)

The "add a new record on the fly" does not respect the "limit_choices_to":

Reported by: david@… Owned by: nobody
Component: contrib.admin 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

If the 'nl_group' field is defined as

  nl_group = models.ForeignKey('self', limit_choices_to = {'o1type__exact': 'NL'}, null=True, blank=True)

Then the pop up window after clicking the 'green plus' sign has an o1type with its normal default value. This means that the relationship will be broken. The o1type should default to 'NL' so that the relationship is not broken.

For many of the possible values of "limit_choices_to" a correct default value may be inferred. Other possible simpler solutions include adding a new parameter: e.g.

onfly_add_defaults = {'o1type': 'NL'}

Change History (3)

comment:1 Changed 10 years ago by david@…

To make this rock solid, the "limit_choices_to" predicate should also be included as a record level validation test during 'on-the-fly' adds. Failure could be reported as "The record you are attempting to add would not appear in the list box to the left of the green plus." Or something to this effect.

David

comment:2 Changed 9 years ago by Chris Beaven

Dupe of #29

comment:3 Changed 9 years ago by James Bennett

Resolution: duplicate
Status: newclosed

Looks like Chris forgot to close this when he marked it a dupe.

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