#27563: Move "Apply limit_choices_to" code from BaseModelForm to
fields_for_model()
------------------------------------------------+------------------------
Reporter: Jon Dufresne | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Forms | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
I frequently use `fields_for_model()` to generate form fields dynamically
on a model form. The form may have different fields based on the request,
system settings, or other input. Using `fields_for_model()` is very
convenient to build these dynamic fields. For the most part, it is built
consistently had the field originally been defined on `Meta.fields`.
One shortfall I noticed, `limit_choices_to` is not applied to form field
querysets the way it typically is for `ModelForm`s. To make the
`fields_for_model()` function more convenient and consistent with fields
generated by `ModelForm`, I'd like to suggest moving the "Apply
limit_choices_to" code from `BaseModelForm` to `fields_for_model()`.
Currently here:
https://github.com/django/django/blob/3507d4e773aa9ff2336e7230ba231c4ba6eb568f/django/forms/models.py#L294-L300
Suggested location:
https://github.com/django/django/blob/3507d4e773aa9ff2336e7230ba231c4ba6eb568f/django/forms/models.py#L172-L173
--
Ticket URL: <https://code.djangoproject.com/ticket/27563>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.71e75f22555214c9f2f5cc95a16c33ba%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.