Render config Netbox v3.6.4 #16172
Unanswered
RandyRozo
asked this question in
Help Wanted!
Replies: 1 comment 2 replies
-
That template works for me in Netbox 3.7.8 / Python 3.8.10. Is that the entire template, or is there some other part before this? Somehow "device" seems to be set to a string, not an object. Can you replicate this at demo.netbox.dev ? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Netbox v3.6.4
I have the following jinja2 template but it is not rendering, I do not get the hostname and I get the following error in 'interfaces'
Config Template
hostname {{ device.name }}
{% for interface in device.interfaces.all() %}
interface {{ interface.name }}
switchport mode access
switchport access vlan {{ interface.untagged_vlan.vid }}
{% endfor %}
Error
Traceback (most recent call last):
File "/opt/netbox/netbox/dcim/views.py", line 2071, in get_extra_context
rendered_config = config_template.render(context=context_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/netbox/extras/models/configs.py", line 280, in render
output = template.render(**_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/venv/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/opt/netbox/venv/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "", line 3, in top-level template code
File "/opt/netbox/venv/lib/python3.11/site-packages/jinja2/sandbox.py", line 326, in getattr
value = getattr(obj, attribute)
^^^^^^^^^^^^^^^^^^^^^^^
jinja2.exceptions.UndefinedError: 'str object' has no attribute 'interfaces'
Beta Was this translation helpful? Give feedback.
All reactions