Opened 10 years ago
Last modified 10 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: | dev |
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 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 10 years ago
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 by , 10 years ago
charettes, how would you convert limit_choices_to
in the way you mention?
comment:4 by , 10 years ago
@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.
Makes sense to me, and verified that this is indeed not happening already.