How to get assigned_object_type_id in netbox script #19505
-
Hello,
What is the correct was to get the assigned_object_type_id? Thank you very much! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi there, You're absolutely right that if you specifically need the ID of the interface_ct = ContentType.objects.get_for_model(Interface).pk is the correct way to get it. However, if your goal is just to assign the interface to the IP address, you don’t need to deal with newIP.assigned_object = vlanOneInterface This is cleaner and lets NetBox handle the content type association for you. Hope that helps! |
Beta Was this translation helpful? Give feedback.
Hi there,
You're absolutely right that if you specifically need the ID of the
ContentType
, then using:is the correct way to get it.
However, if your goal is just to assign the interface to the IP address, you don’t need to deal with
assigned_object_type_id
orassigned_object_id
directly. Instead, you can simply do:This is cleaner and lets NetBox handle the content type association for you.
Hope that helps!