Remove all limit_choices_to attributes on ForeignKey & ManyToMany fields #10094

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

Originally created by @jeremystretch on GitHub (Aug 14, 2024).

Originally assigned to: @jeremystretch on GitHub.

Proposed Changes

Remove the limit_choices_to attribute on the following model fields:

  • CircuitTermination.termination_type
  • CircuitGroupAssignment.member_type
  • CableTermination.termination_type
  • InventoryItemTemplate.component_type
  • InventoryItem.component_type
  • MACAddress.assigned_object_type
  • IPAddress.assigned_object_type
  • Prefix.scope_type
  • VLANGroup.scope_type
  • ObjectPermission.object_types
  • Cluster.scope_type
  • VirtualMachine.role
  • L2VPNTermination.assigned_object_type
  • WirelessLAN.scope_type
  • WirelessLink.interface_a
  • WirelessLink.interface_b

Justification

The limit_choices_to attribute was originally used to limit the selection of related objects for a field within a ModelForm. It is no longer needed as we explicitly declare these fields inside each ModelForm to employ dynamic selections via the REST API.

Originally created by @jeremystretch on GitHub (Aug 14, 2024). Originally assigned to: @jeremystretch on GitHub. ### Proposed Changes Remove the `limit_choices_to` attribute on the following model fields: - `CircuitTermination.termination_type` - `CircuitGroupAssignment.member_type` - `CableTermination.termination_type` - `InventoryItemTemplate.component_type` - `InventoryItem.component_type` - `MACAddress.assigned_object_type` - `IPAddress.assigned_object_type` - `Prefix.scope_type` - `VLANGroup.scope_type` - `ObjectPermission.object_types` - `Cluster.scope_type` - `VirtualMachine.role` - `L2VPNTermination.assigned_object_type` - `WirelessLAN.scope_type` - `WirelessLink.interface_a` - `WirelessLink.interface_b` ### Justification The [`limit_choices_to`](https://docs.djangoproject.com/en/5.1/ref/models/fields/#django.db.models.ForeignKey.limit_choices_to) attribute was originally used to limit the selection of related objects for a field within a ModelForm. It is no longer needed as we explicitly declare these fields inside each ModelForm to employ dynamic selections via the REST API.
adam added the status: acceptedtype: housekeepingnetbox labels 2025-12-29 21:26:48 +01:00
adam closed this issue 2025-12-29 21:26:49 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 14, 2024):

Blocked by #10136

@jeremystretch commented on GitHub (Aug 14, 2024): Blocked by #10136
Author
Owner

@jeremystretch commented on GitHub (Apr 3, 2025):

This can be completed without #10136, although we should still try to complete that work.

@jeremystretch commented on GitHub (Apr 3, 2025): This can be completed without #10136, although we should still try to complete that work.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10094