Custom fields not rendered in export templates using Jinja2 #2617

Closed
opened 2025-12-29 18:20:27 +01:00 by adam · 3 comments
Owner

Originally created by @ewysong on GitHub (May 16, 2019).

Environment

  • Python version: 3.6.6
  • NetBox version: 2.5.12

Steps to Reproduce

  1. Create a custom field in the Admin section under Extras > Custom Fields
    1

  2. Populate an object's custom fields with data

  3. Create an Export Template in the Admin section under Extras > Export templates
    2

  4. Perform an export using the created Export Template from step 2 of an object with the custom field objects populated.

Expected Behavior

Exports would include the custom field in the export as documented at https://netbox.readthedocs.io/en/latest/additional-features/export-templates/#export-templates

Observed Behavior

There is nothing in the export for the custom fields, even though there is data present in the custom fields for the exported objects.

Discussion on mailing list: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/netbox-discuss/8aTZFNEKr2s/zon4QXbvAQAJ

Originally created by @ewysong on GitHub (May 16, 2019). ### Environment * Python version: 3.6.6 * NetBox version: 2.5.12 ### Steps to Reproduce 1. Create a custom field in the Admin section under Extras > Custom Fields ![1](https://user-images.githubusercontent.com/17579891/57867149-951a2e00-77ce-11e9-8b0a-594321b23827.png) 2. Populate an object's custom fields with data 3. Create an Export Template in the Admin section under Extras > Export templates ![2](https://user-images.githubusercontent.com/17579891/57867308-e4605e80-77ce-11e9-93c1-97e6a7269243.png) 4. Perform an export using the created Export Template from step 2 of an object with the custom field objects populated. ### Expected Behavior Exports would include the custom field in the export as documented at https://netbox.readthedocs.io/en/latest/additional-features/export-templates/#export-templates ### Observed Behavior There is nothing in the export for the custom fields, even though there is data present in the custom fields for the exported objects. Discussion on mailing list: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/netbox-discuss/8aTZFNEKr2s/zon4QXbvAQAJ
adam added the type: bugstatus: accepted labels 2025-12-29 18:20:27 +01:00
adam closed this issue 2025-12-29 18:20:27 +01:00
Author
Owner

@jeremystretch commented on GitHub (May 17, 2019):

Just wanted to note that this only affects export templates written in Jinja2; templates using the original Django language are unaffected.

@jeremystretch commented on GitHub (May 17, 2019): Just wanted to note that this only affects export templates written in Jinja2; templates using the original Django language are unaffected.
Author
Owner

@jeremystretch commented on GitHub (May 17, 2019):

For future reference: The root issue here is that cf was defined as a method on CustomFieldModel, rather than an attribute. This has worked in the past because the Django templating language will attempt to resolve an attribute as a method, however Jinja2 will not. It has been changed to a property to avoid this issue in Jinja2 while maintaining backward compatibility with Django.

@jeremystretch commented on GitHub (May 17, 2019): For future reference: The root issue here is that `cf` was defined as a method on CustomFieldModel, rather than an attribute. This has worked in the past because the Django templating language will attempt to resolve an attribute as a method, however Jinja2 will not. It has been changed to a property to avoid this issue in Jinja2 while maintaining backward compatibility with Django.
Author
Owner

@ewysong commented on GitHub (May 17, 2019):

Awesome, thanks for the quick fix, as well as all of your work on the project as a whole!

@ewysong commented on GitHub (May 17, 2019): Awesome, thanks for the quick fix, as well as all of your work on the project as a whole!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2617