Export device template with interfaces

667 views
Skip to first unread message

Gaspar

unread,
Feb 9, 2021, 10:12:15 AM2/9/21
to NetBox
Hi,

It is possible to make a export template with the information of the interfaces?
I'm trying to use in "dcim | device" this way, but give me the error "There was an error rendering the selected export template (Export Devices): 'method' object is not iterable"

    {% for device in queryset %}
            host_name               {{ device.name }}
            Site                    {{ device.site.region }} / {{ device.site }}
            address                 {{ device.primary_ip.address.ip }}
            Rack / Position         {{ device.rack }} / {{ device.position }}
            Belongs to:             {{ device.tenant.group }} / {{ device.tenant }}
            Device Type:            {{ device.device_type }} / {{ device.device_type.manufacturer }}
            Device Serial:          {{ device.serial }}

     {% for interface in device.interfaces.all %}
     {{ interface.name }}
     {% endfor %}

     {% endfor %}

Thanks.

Jeremy Stretch

unread,
Feb 9, 2021, 12:47:36 PM2/9/21
to Gaspar, NetBox
Under Jinja2, you need to add the parentheses when calling a method, e.g. device.interfaces.all()

--
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 netbox-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/337bb0ea-a9c9-47a6-bf47-3c94048aa2e3n%40googlegroups.com.


--
Jeremy Stretch
Founder
NetVerity, LLC

Gaspar

unread,
Feb 9, 2021, 4:24:44 PM2/9/21
to NetBox
Thanks,

It was my first template.

Is there any page with the possible methods and variables for the export templates?

Thanks again

Reply all
Reply to author
Forward
0 new messages