-
I am creating a device export template. I am trying to include the devices parent device name using the following code {{ device.parent_bay.device.name }}. When I runt the export I get the error "There was an error rendering the selected export template (Device Export): 'dcim.models.devices.Device object' has no attribute 'parent_bay'" When I look at the nbshell and run that query, it returns the parent device name. What am I doing wrong. Thank in advance. Template Code: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Are all the devices you are exporting "child" devices? My guess is you have some devices matching your filter that aren't "child" devices, which explains why the field doesn't exist on those. To prevent it from erroring, I believe you just need an if statement to check for device.parent_bay. Example:
If that doesn't work, you can check to see if it is a child device:
|
Beta Was this translation helpful? Give feedback.
Are all the devices you are exporting "child" devices? My guess is you have some devices matching your filter that aren't "child" devices, which explains why the field doesn't exist on those. To prevent it from erroring, I believe you just need an if statement to check for device.parent_bay.
Example:
If that doesn't work, you can check to see if it is a child device: