A proper way to deal with export templates #8065
-
Hi. I have a problem creating a proper "Export Templates" and need a little help. Using netbox 3.1.1.
I read https://demo.netbox.dev/static/docs/customization/export-templates/ and tried to export from "Custom Field" a "Content types" for which I used "content_types" field name (which is the name taken from import field name). I used: and instead of getting something like: Though that is a bug, but @jeremystretch pointed out in #8062 that it it not. I'm kind of surprised and I am wondering what is the best way to get the list of attributes that "obj" holds plus their values. The best would be to just craft some "generic" template and use it to export all data just to get a sneak peek of "obj" attributes and values so in the next step one would be able to make a proper, more detailed template. If this is impossible then what is the best way to get such info? API? Source code? Something else?
For example:
How to properly extract empty value from "{{ tenant.group }}" using "Export Template" when Group is not set ? Many thanks in advance for help. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
To explore what attributes are available on a given object, the nbshell is a useful tool.
The source code for the model is also a good place to look, e.g. for Device |
Beta Was this translation helpful? Give feedback.
-
Thank you @candlerb for the hint will look into that. Regarding second question - @kkthxbye-code pointed out that for "{{ tenant.group }}" I should use "{{ tenant.group|default('', true) }}" which works in this case. Thank you again @kkthxbye-code . |
Beta Was this translation helpful? Give feedback.
To explore what attributes are available on a given object, the nbshell is a useful tool.
The source code for the model is also a good place to look, e.g. for Device