How to filter InterfaceTemplate ObjectVar in custom script? #15535
-
|
I'm trying to build a custom script to add devices. First you select a This approach works fine for other object types, for example I can filter from dcim.models import *
from extras.scripts import *
class FormDebug(Script):
class Meta:
"""Meta Class."""
name = "Form Debug"
device_type = ObjectVar(model=DeviceType)
primary_nic = ObjectVar(
model=InterfaceTemplate,
query_params={'device_type_id': '$device_type'}
)
def run(self, data, commit):
self.log_info(f"Entered data: {data}")This filter works fine in nbshell: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
The filterset field is called devicetype_id, not device_type_id. |
Beta Was this translation helpful? Give feedback.
The filterset field is called devicetype_id, not device_type_id.
https://github.com/netbox-community/netbox/blob/d2fee886001e4abbcb1b4d9ed3fd32521c820be9/netbox/dcim/filtersets.py#L642C5-L646