mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-19 17:59:11 -06:00
Note that 'table' is a reserved name for ExportTemplates
This commit is contained in:
parent
30e4504ee5
commit
93353e94a2
@ -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/).
|
||||
|
||||
|
@ -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):
|
||||
"""
|
||||
|
@ -5,7 +5,7 @@
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li><a href="?{% if url_params %}{{ url_params.urlencode }}&{% endif %}export=table">Current view</a></li>
|
||||
<li><a href="?{% if url_params %}{{ url_params.urlencode }}&{% endif %}export">Default format</a></li>
|
||||
<li><a href="?{% if url_params %}{{ url_params.urlencode }}&{% endif %}export">Legacy CSV</a></li>
|
||||
{% if export_templates %}
|
||||
<li class="divider"></li>
|
||||
{% for et in export_templates %}
|
||||
|
Loading…
Reference in New Issue
Block a user