Cables Permissions Restrictions #6157

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

Originally created by @Wyvern77 on GitHub (Mar 1, 2022).

NetBox version

v3.1.8

Python version

3.8

Steps to Reproduce

  1. Attempt to restrict where cables are created to specific regions or custom fields etc..
  2. Create a permissions object for "cable" and attempt to use constraints to limit to a specific region. Example contstraint [{"termination_a__device__site__region__parent__name": "Europe"}]
  3. When saving the following error is created: "Invalid filter for <class 'dcim.models.cables.Cable'>: Field 'termination_a' does not generate an automatic reverse relation and therefore cannot be used for reverse querying. If it is a GenericForeignKey, consider adding a GenericRelation."

Expected Behavior

I had expected the same behaviour as I found when applying the same logic to other objects such as "devices", "inventory","interfaces", etc.

Observed Behavior

Error in the admin portal when saving the permission with a constraint based on device region.

Invalid filter for <class 'dcim.models.cables.Cable'>: Field 'termination_a' does not generate an automatic reverse relation and therefore cannot be used for reverse querying. If it is a GenericForeignKey, consider adding a GenericRelation.

Originally created by @Wyvern77 on GitHub (Mar 1, 2022). ### NetBox version v3.1.8 ### Python version 3.8 ### Steps to Reproduce 1. Attempt to restrict where cables are created to specific regions or custom fields etc.. 2. Create a permissions object for "cable" and attempt to use constraints to limit to a specific region. Example contstraint [{"termination_a__device__site__region__parent__name": "Europe"}] 3. When saving the following error is created: "Invalid filter for <class 'dcim.models.cables.Cable'>: Field 'termination_a' does not generate an automatic reverse relation and therefore cannot be used for reverse querying. If it is a GenericForeignKey, consider adding a GenericRelation." ### Expected Behavior I had expected the same behaviour as I found when applying the same logic to other objects such as "devices", "inventory","interfaces", etc. ### Observed Behavior Error in the admin portal when saving the permission with a constraint based on device region. Invalid filter for <class 'dcim.models.cables.Cable'>: Field 'termination_a' does not generate an automatic reverse relation and therefore cannot be used for reverse querying. If it is a GenericForeignKey, consider adding a GenericRelation.
adam added the type: bug label 2025-12-29 19:37:26 +01:00
adam closed this issue 2025-12-29 19:37:26 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 4, 2022):

I don't think this a bug really, just something that's not supported. As the error message indicates, it's not possible to filter on generic foreign key relationships in such a manner.

@jeremystretch commented on GitHub (Mar 4, 2022): I don't think this a bug really, just something that's not supported. As the error message indicates, it's not possible to filter on generic foreign key relationships in such a manner.
Author
Owner

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

I'm going to close this out as inactionable per my note above. If anyone would like to take a stab at implementing such functionality, please feel free to submit a feature request with a functional PoC.

@jeremystretch commented on GitHub (Mar 24, 2022): I'm going to close this out as inactionable per my note above. If anyone would like to take a stab at implementing such functionality, please feel free to submit a feature request with a functional PoC.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6157