Skip to content

Error in export template silently causes the default export to be used instead #7813

@candlerb

Description

@candlerb

NetBox version

v3.0.9

Python version

3.8

Steps to Reproduce

Create a new export template:

  • Content Type: dcim | cable
  • Name: Cables for CSV re-import
  • Template as follows:
side_a_device,side_a_type,side_a_name,side_b_device,side_b_type,side_b_name,type,status,label,color,length,length_unit
{%- for c in queryset %}
{%- set lenitems = c.length.split(' ') %}
{{ c.termination_a.device.name }},
{{ c.termination_a_type.app_labeled_name }},{{ c.termination_a.name }},{{ c.termination_b.device.name }},
{{ c.termination_b_type.app_labeled_name }},{{ c.termination_b.name }},{{ c.type }},{{ c.status }},{{ c.label }},{{ lenitems[0] }},{{ lenitems[1] }}
{%- endfor %}

Now browse to cables, select a filter which limits them to a single device.

Click on Export > Cables for CSV Import

image

This links to dcim/cables/?q=&device_id=952&type=&status=&color=&export=Cables%20for%20CSV%20re-import

Expected Behavior

The downloaded CSV file would be formatted in accordance with the given template

OR: if the template is invalid, that an error would be reported.

Observed Behavior

The file netbox_cables.csv which is generated uses the default CSV formatting, ignoring the selected export template:

ID,Label,Side A,Termination A,Side B,Termination B,Status,Type,Length,Color,Tags
1791,,ldex-r17-sw1,PSU,PDU-R17-1,OUT24,Connected,Power,,,
1808,,ldex-r17-sw1,Gi1/0/24,mod-rj45-r17-r18-1-4,F1,Connected,CAT5e,50.00 Centimeters,#ffeb3b,
... etc

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions