Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom field values should be accessible in export templates #561

Closed
jeremystretch opened this issue Sep 16, 2016 · 4 comments
Closed

Custom field values should be accessible in export templates #561

jeremystretch opened this issue Sep 16, 2016 · 4 comments
Labels
type: feature Introduction of new functionality to the application

Comments

@jeremystretch
Copy link
Member

jeremystretch commented Sep 16, 2016

Currently, there is no way to access an object's custom fields from within an export template. Ideally, these fields should be accessible similar to any real attribute. For example, an object with a custom field named color should be accessible as such:

{% for obj in queryset %}
    Color: {{ obj.cf.color }}
{% endfor %}

We want to use a designated attribute (cf) to avoid collisions with existing attributes.

@jeremystretch jeremystretch added the type: feature Introduction of new functionality to the application label Sep 16, 2016
@jeremystretch
Copy link
Member Author

Of course, immediately after releasing v1.6.1, I realize that I never finished renaming the get_custom_fields method, so cf() doesn't actually work inside export templates.

@jeremystretch
Copy link
Member Author

Fixed in 325d96d

if-fi pushed a commit to if-fi/netbox that referenced this issue Oct 1, 2016
if-fi pushed a commit to if-fi/netbox that referenced this issue Oct 1, 2016
@DevilWAH
Copy link

Hi I know this is closed but what if the custome fieled has space in name? "CDE Scoped"

{{ device.name }} ,{{ device.serial }},{{ device.primary_ip }},{{ device.cf }}
works, if a bit messy.
but
{{ device.name }} ,{{ device.serial }},{{ device.primary_ip }},{{ device.cf.cde-scoped ]]

gives a rendering error?

@jeremystretch
Copy link
Member Author

Didn't think spaces were valid in the name but it appears they are. They shouldn't be. Just use an underscore or hyphen in the field name instead of a space. You can set a separate human-friendly label to be displayed on the UI.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

2 participants