CSV export with custom object(s) #1724

Closed
opened 2025-12-29 16:34:44 +01:00 by adam · 6 comments
Owner

Originally created by @tomowaw on GitHub (May 11, 2018).

[x ] Feature request
[ ] Bug report
[ ] Documentation

  • NetBox version: 2.3.3

Hi,

is there any posibility to add in export to csv custom fields (they are relatied to obejcts)?
My example:
I have added a new custom field in "django administration", extras -> custom fields.
Obejct (s) -> dcim -> device, type -> date, name -> "warranty"
This is useful to export those data to file and sort as you wish or give this file to managers.
In main view -> devices -> devices -> export in exported csv there are only build-in fields / attributes.

Regards,
Tomasz

Originally created by @tomowaw on GitHub (May 11, 2018). [x ] Feature request [ ] Bug report [ ] Documentation * NetBox version: 2.3.3 Hi, is there any posibility to add in export to csv custom fields (they are relatied to obejcts)? My example: I have added a new custom field in "django administration", extras -> custom fields. Obejct (s) -> dcim -> device, type -> date, name -> "warranty" This is useful to export those data to file and sort as you wish or give this file to managers. In main view -> devices -> devices -> export in exported csv there are only build-in fields / attributes. Regards, Tomasz
adam closed this issue 2025-12-29 16:34:44 +01:00
Author
Owner

@Bill-Irvine commented on GitHub (May 16, 2018):

You can export custom fields by creating an export template for the object.
https://netbox.readthedocs.io/en/latest/data-model/extras/#export-templates

@Bill-Irvine commented on GitHub (May 16, 2018): You can export custom fields by creating an export template for the object. https://netbox.readthedocs.io/en/latest/data-model/extras/#export-templates
Author
Owner

@tomowaw commented on GitHub (May 19, 2018):

Thanks for the link.
The example is difficult to understand :/
If I understand correctly, I am moving around the object, eg a device
My custom field in extras is related to object device, name -> Warranty
using sytnax {{ obj.cf.Warranty }} do not return any data :(

Does custom field/Warranty is case sensitive?
How to export something else from other tables example deive role?

Thx
centos_netbox_extras_01
centos_netbox_extras_02
centos_netbox_extras_03
centos_netbox_extras_04
centos_netbox_extras_05
centos_netbox_extras_06

@tomowaw commented on GitHub (May 19, 2018): Thanks for the link. The example is difficult to understand :/ If I understand correctly, I am moving around the object, eg a **device** My custom field in extras is related to object **device**, name -> **Warranty** using sytnax {{ obj.cf.Warranty }} do not return any data :( Does custom field/Warranty is case sensitive? How to export something else from other tables example deive role? Thx ![centos_netbox_extras_01](https://user-images.githubusercontent.com/20935414/40272618-8cd23e76-5bb0-11e8-9f28-3ca1c735c597.png) ![centos_netbox_extras_02](https://user-images.githubusercontent.com/20935414/40272619-8cf0e9d4-5bb0-11e8-95fb-c1d797b2b016.png) ![centos_netbox_extras_03](https://user-images.githubusercontent.com/20935414/40272620-8d0e15c2-5bb0-11e8-8559-50cd3092b9f4.png) ![centos_netbox_extras_04](https://user-images.githubusercontent.com/20935414/40272621-8d2b5948-5bb0-11e8-91db-a0ba7a25095b.png) ![centos_netbox_extras_05](https://user-images.githubusercontent.com/20935414/40272622-8d46e64a-5bb0-11e8-876f-90d92c1ce817.png) ![centos_netbox_extras_06](https://user-images.githubusercontent.com/20935414/40272623-8d64b4f4-5bb0-11e8-8659-5b0d67cc2062.png)
Author
Owner

@jeremystretch commented on GitHub (May 22, 2018):

Does custom field/Warranty is case sensitive?

Yes. Use the actual field name as it appears under the list in the admin UI, e.g. warranty. If you need any further assistance, please post to the mailing list.

@jeremystretch commented on GitHub (May 22, 2018): > Does custom field/Warranty is case sensitive? Yes. Use the actual field name as it appears under the list in the admin UI, e.g. `warranty`. If you need any further assistance, please post to the mailing list.
Author
Owner

@tomowaw commented on GitHub (May 22, 2018):

Jeremy but it doesn't work.
Did you read my post?
With this template code the only returned value are device.name :(

{% for device in queryset %}
Name: {{ device.name }}
Try1: {{ Warranty }}
Try2: {{ obj.cf.Warranty }}
Try3: {{ warranty }}
Try4: {{ obj.cf.warranty }}
Try5: {{ cf.warranty }}
Try6: {{ cf.Warranty }}
{% endfor %}

@tomowaw commented on GitHub (May 22, 2018): Jeremy but it doesn't work. Did you read my post? With this template code the only returned value are device.name :( {% for device in queryset %} Name: {{ device.name }} Try1: {{ Warranty }} Try2: {{ obj.cf.Warranty }} Try3: {{ warranty }} Try4: {{ obj.cf.warranty }} Try5: {{ cf.warranty }} Try6: {{ cf.Warranty }} {% endfor %}
Author
Owner

@Bill-Irvine commented on GitHub (May 23, 2018):

@tomowaw "obj" is representative of the objects within Netbox (circuit,device,etc)

try {{ device.cf.warranty }}

@Bill-Irvine commented on GitHub (May 23, 2018): @tomowaw "obj" is representative of the objects within Netbox (circuit,device,etc) try {{ device.cf.warranty }}
Author
Owner

@tomowaw commented on GitHub (Jun 8, 2018):

Thx @Bill-Irvine
@jeremystretch can you update info/readthedocs about extras -> export tamplate?
As Bill said the object is circuit, device etc. I figured it out!

Helpful thing is "api" in netbox. Reading output from example "device instance" -> GET /api/dcim/devices/2/ where 2 is ID is much simple to create export template (ID can be omitted).
^^ I'm talking about link -> http://ip_or_hostname/api/dcim/device/ID/

My export template with custom field -> warranty:

Template code:

Name;Warranty;Serial;Manuf
{% for device in queryset %}{{device.name}};{{device.cf.warranty}};{{device.serial}};{{device.device_type.manufacturer.name}}
{% endfor %}

Regards,
Tomasz

@tomowaw commented on GitHub (Jun 8, 2018): Thx @Bill-Irvine @jeremystretch can you update info/readthedocs about extras -> export tamplate? As Bill said the object is circuit, device etc. I figured it out! Helpful thing is "api" in netbox. Reading output from example "device instance" -> GET /api/dcim/devices/2/ where 2 is ID is much simple to create export template (ID can be omitted). ^^ I'm talking about link -> http://ip_or_hostname/api/dcim/device/_ID/_ My export template with custom field -> warranty: Template code: Name;Warranty;Serial;Manuf {% for device in queryset %}{{device.name}};{{device.cf.warranty}};{{device.serial}};{{device.device_type.manufacturer.name}} {% endfor %} Regards, Tomasz
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1724