Opened 4 years ago

Last modified 3 years ago

#23595 assigned Cleanup/optimization

“add” button for related fields in admin interface should send 'limit_choices_to' parameter to add form

Reported by: Marco Aurélio de Araújo Silva Owned by: Greg Chapple
Component: contrib.admin Version: master
Severity: Normal Keywords:
Cc: cmawebsite@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description

I think it's self-explanatory. When the related field has a 'limit_choices_to' parameter, the new object added to the related class should have that field pre-defined with the 'limit_choices_to' value.

Change History (6)

comment:1 Changed 4 years ago by Greg Chapple

Owner: changed from nobody to Greg Chapple
Status: newassigned
Triage Stage: UnreviewedAccepted

Makes sense to me, and verified that this is indeed not happening already.

comment:2 Changed 4 years ago by Simon Charette

The correct way of doing this would be to convert limit_choices_to to form level constraints and not to populate concerned fields.

i.e. how would you populate a field based on limit_choices_to = {'integer_field__gte': 3}?

comment:3 Changed 4 years ago by Greg Chapple

charettes, how would you convert limit_choices_to in the way you mention?

comment:4 Changed 4 years ago by Simon Charette

@gchp, Django doesn't provide any helper to do such a thing which might be the reason why this feature hasn't been implemented yet.

I was just pointing out that converting limit_choices_to to form initial data is a naive approach since you're not enforcing anything and that it has many limitations such as the one provided above.

comment:5 Changed 4 years ago by Greg Chapple

@charettes, fair enough. I'll give it a go, anyways!

comment:6 Changed 3 years ago by Collin Anderson

Cc: cmawebsite@… added

Maybe this will solve #29 :)

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