Add Jinja2 support for export templates #2504

Closed
opened 2025-12-29 18:19:27 +01:00 by adam · 1 comment
Owner

Originally created by @jeremystretch on GitHub (Apr 8, 2019).

Environment

  • Python version: 3.5.6
  • NetBox version: 2.5.9

Proposed Functionality

NetBox allows users to create arbitrary export templates for objects. Currently, these templates must be written in Django's native templating language. This request seeks to add Jinja2 as an alternate template language. While Jinja2 and Django's templating languae are very similar, Jinja2 has the advantages of being more flexible and more commonly understood.

Use Case

Jinja2 allows for more complex language within templates, whereas Django's template language is intentionally limited (with the design goal of pushing logic into the view component of Django's MVT framework).

Database Changes

Add a "template language" field to the ExportTemplate model. This will be set to Django for all existing templates but will default to Jinja2 for all new templates.

External Dependencies

Jinja2 is currently pulled in as a dependency by drf-yasg. It will be listed in requirements.txt as a top-level dependency but should not have any noticeable effect on existing installations.

Originally created by @jeremystretch on GitHub (Apr 8, 2019). ### Environment * Python version: 3.5.6 * NetBox version: 2.5.9 ### Proposed Functionality NetBox allows users to create arbitrary export templates for objects. Currently, these templates must be written in Django's native templating language. This request seeks to add Jinja2 as an alternate template language. While Jinja2 and Django's templating languae are very similar, Jinja2 has the advantages of being more flexible and more commonly understood. ### Use Case Jinja2 allows for more complex language within templates, whereas Django's template language is intentionally limited (with the design goal of pushing logic into the view component of Django's MVT framework). ### Database Changes Add a "template language" field to the ExportTemplate model. This will be set to Django for all existing templates but will default to Jinja2 for all new templates. ### External Dependencies Jinja2 is currently pulled in as a dependency by `drf-yasg`. It will be listed in `requirements.txt` as a top-level dependency but should not have any noticeable effect on existing installations.
adam added the status: acceptedtype: feature labels 2025-12-29 18:19:27 +01:00
adam closed this issue 2025-12-29 18:19:27 +01:00
Author
Owner

@Grokzen commented on GitHub (Apr 9, 2019):

@jeremystretch This feature really needs to have docs added to it here https://github.com/digitalocean/netbox/edit/master/docs/additional-features/export-templates.md

@Grokzen commented on GitHub (Apr 9, 2019): @jeremystretch This feature really needs to have docs added to it here https://github.com/digitalocean/netbox/edit/master/docs/additional-features/export-templates.md
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2504