netbox/docs/models/extras/exporttemplate.md
Renato Almeida de Oliveira fbd6d8c7fc
Closes #17653: Add function to trim whitespaces in export templates via jinja environment settings (#19078)
* Create RenderMixin, and unify template_code rendering and exporting

* Join migrations

* Add DEFAULT_MIME_TE constant

* Move RenderMixin to extras.models.mixins, Rename RenderMixin to RenderTemplateMixin

* Add render_jinja2 to __all__

* Rename ConfigTemplateFilterForm rendering FieldSet

* ConfigTemplate lint

* Simplify ExportTemplate get_context

* Fix table order, and add fields for translations

* Update Serializers

* Update forms, tables, graphQL, API

* Add extra tests for ConfigTemplate and ExportTemplate

* Documentation update

* Fix typo

* Misc cleanup

* Clean up template layouts

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2025-04-08 10:37:15 -04:00

1.7 KiB

Export Templates

Export templates are used to render arbitrary data from a set of NetBox objects. For example, you might want to automatically generate a network monitoring service configuration from a list of device objects. See the export templates documentation for more information.

Fields

Name

The name of the export template. This will appear in the "export" dropdown list in the NetBox UI.

Content Type

The type of NetBox object to which the export template applies.

Data File

Template code may optionally be sourced from a remote data file, which is synchronized from a remote data source. When designating a data file, there is no need to specify local content for the template: It will be populated automatically from the data file.

Template Code

Jinja2 template code for rendering the exported data.

Environment Parameters

!!! info "This field was introduced in NetBox v4.3."

A dictionary of any additional parameters to pass when instantiating the Jinja2 environment. Jinja2 supports various optional parameters which can be used to modify its default behavior.

MIME Type

The MIME type to indicate in the response when rendering the export template (optional). Defaults to text/plain.

File Name

The file name to give to the rendered export file (optional).

File Extension

The file extension to append to the file name in the response (optional).

As Attachment

If selected, the rendered content will be returned as a file attachment, rather than displayed directly in-browser (where supported).