Exclude limit_choices_to attribute from field deconstruction for migration planning #6870

Open
opened 2025-12-29 19:46:14 +01:00 by adam · 1 comment
Owner

Originally created by @jeremystretch on GitHub (Aug 24, 2022).

Proposed Changes

Extend our custom field deconstruction method to exclude a field's limit_choices_to attribute in addition to choices, help_text, and verbose_name (which are already excluded).

Justification

Changes to the limit_choices_to attribute on a field do not effect a database schema change. (In fact, we have many instances where the use of FeatureQuery() results in the dynamic calculation of acceptable values at runtime.) Excluding this attribute from consideration avoids creating "no-op" migrations which clutter the application.

Originally created by @jeremystretch on GitHub (Aug 24, 2022). ### Proposed Changes Extend our custom [field deconstruction method](https://github.com/netbox-community/netbox/blob/c2c8bd0a761dde32bc2438abf6c05fd27fab58c3/netbox/utilities/management/commands/__init__.py#L20) to exclude a field's `limit_choices_to` attribute in addition to `choices`, `help_text`, and `verbose_name` (which are already excluded). ### Justification Changes to the `limit_choices_to` attribute on a field do not effect a database schema change. (In fact, we have many instances where the use of `FeatureQuery()` results in the dynamic calculation of acceptable values at runtime.) Excluding this attribute from consideration avoids creating "no-op" migrations which clutter the application.
adam added the type: housekeepingnetboxstatus: backlog labels 2025-12-29 19:46:14 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 24, 2022):

We can actually ignore related_name and related_query_name as well, and simply bypass RelatedField's deconstruct() method entirely. We'll need to do some extensive testing before implementing this change, however.

@jeremystretch commented on GitHub (Aug 24, 2022): We can actually ignore `related_name` and `related_query_name` as well, and simply bypass RelatedField's `deconstruct()` method entirely. We'll need to do some extensive testing before implementing this change, however.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6870