Remove ChainedFieldsMixin #3156

Closed
opened 2025-12-29 18:26:11 +01:00 by adam · 2 comments
Owner

Originally created by @hSaria on GitHub (Jan 13, 2020).

Originally assigned to: @jeremystretch on GitHub.

Proposed Changes

Remove the ChainedFieldsMixin, ChainedModelChoiceField, and ChainedModelMultipleChoiceField.

Justification

Chaining has been replaced with APISelect's filter_for and is no longer required. It updates the queryset, but it is entirely ignored by the API call. And ever since #3812, only the selected option (if any) in the queryset is rendered, so limiting makes very little difference.

Originally created by @hSaria on GitHub (Jan 13, 2020). Originally assigned to: @jeremystretch on GitHub. ### Proposed Changes Remove the `ChainedFieldsMixin`, `ChainedModelChoiceField`, and `ChainedModelMultipleChoiceField`. ### Justification Chaining has been replaced with APISelect's `filter_for` and is no longer required. It updates the queryset, but it is entirely ignored by the API call. And ever since #3812, only the selected option (if any) in the queryset is rendered, so limiting makes very little difference.
adam added the status: acceptedtype: housekeeping labels 2025-12-29 18:26:11 +01:00
adam closed this issue 2025-12-29 18:26:11 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jan 17, 2020):

This isn't as simple as just ripping out the chained fields logic, unfortunately. There's more going on here than UI rendering: Foreign key fields frequently need to have their querysets limited in various scenarios to avoid thrashing the database during form validation. It's no doubt something we should look into eventually but it's a huge project and not a priority at this time.

@jeremystretch commented on GitHub (Jan 17, 2020): This isn't as simple as just ripping out the chained fields logic, unfortunately. There's more going on here than UI rendering: Foreign key fields frequently need to have their querysets limited in various scenarios to avoid thrashing the database during form validation. It's no doubt something we should look into eventually but it's a huge project and not a priority at this time.
Author
Owner

@hSaria commented on GitHub (Feb 10, 2020):

With #4108 implemented, would it now be safe to remove chaining as the APISelect now limits the queryset to only the existing selection?

@hSaria commented on GitHub (Feb 10, 2020): With #4108 implemented, would it now be safe to remove chaining as the APISelect now limits the queryset to only the existing selection?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3156