diff --git a/docs/additional-features/export-templates.md b/docs/additional-features/export-templates.md index 1e0611f06..950d02d4a 100644 --- a/docs/additional-features/export-templates.md +++ b/docs/additional-features/export-templates.md @@ -2,7 +2,10 @@ NetBox allows users to define custom templates that can be used when exporting objects. To create an export template, navigate to Extras > Export Templates under the admin interface. -Each export template is associated with a certain type of object. For instance, if you create an export template for VLANs, your custom template will appear under the "Export" button on the VLANs list. +Each export template is associated with a certain type of object. For instance, if you create an export template for VLANs, your custom template will appear under the "Export" button on the VLANs list. Each export template must have a name, and may optionally designate a specific export [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) and/or file extension. + +!!! note + The name `table` is reserved for internal use. Export templates must be written in [Jinja2](https://jinja.palletsprojects.com/). diff --git a/netbox/extras/models/models.py b/netbox/extras/models/models.py index 0ff68556e..d54eac0db 100644 --- a/netbox/extras/models/models.py +++ b/netbox/extras/models/models.py @@ -261,7 +261,15 @@ class ExportTemplate(BigIDModel): ] def __str__(self): - return '{}: {}'.format(self.content_type, self.name) + return f"{self.content_type}: {self.name}" + + def clean(self): + super().clean() + + if self.name.lower() == 'table': + raise ValidationError({ + 'name': f'"{self.name}" is a reserved name. Please choose a different name.' + }) def render(self, queryset): """ diff --git a/netbox/utilities/templates/buttons/export.html b/netbox/utilities/templates/buttons/export.html index 341dca3f0..e7e246739 100644 --- a/netbox/utilities/templates/buttons/export.html +++ b/netbox/utilities/templates/buttons/export.html @@ -5,7 +5,7 @@