Permissions, nested objects

Skip to first unread message

Denis Tsygankov

May 20, 2021, 7:45:15 AMMay 20
to NetBox
I want to get a permission to delete devices with a particular manufacturer name.
For example, I have a manufacturer named "GRSM". As per my logic, I need a constraint, something as: 
[{"device_type__manufacturer": {"name": "GRSM"}}]
But got the error below while trying to create it:
<class 'TypeError'>

Field 'id' expected a number but got {'name': 'GRSM'}.

Python version: 3.7.3
NetBox version: 2.11.3
What is the correct way to do what I want?

Denis Tsygankov

May 20, 2021, 8:08:47 AMMay 20
to NetBox
I was able to do what I want. Instead of the manufacturer name I've used its ID. My final constraint is: [{"device_type__manufacturer": 26}]

Jeremy Stretch

May 20, 2021, 8:12:11 AMMay 20
to Denis Tsygankov, NetBox
You can use dunders (double underscores) to navigate related object attributes. So to match many manufacturer name, you would do:

  [{"device_type__manufacturer__name": "GRSM"}]

Hope that helps!

Jeremy Stretch
Distinguished Engineer, NS1
Office of the CTO

You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Brian Candler

May 20, 2021, 8:12:17 AMMay 20
to NetBox
You could also try {"device_type__manufacturer__name": "GRSM"}  [untested]

Denis Tsygankov

May 20, 2021, 8:16:01 AMMay 20
to NetBox
Many thanks, Jeremy and Brian!
Reply all
Reply to author
0 new messages