Extend default MIME type for export templates to specify UTF-8 #7812

Closed
opened 2025-12-29 20:28:31 +01:00 by adam · 5 comments
Owner

Originally created by @gdprdatasubect on GitHub (Mar 30, 2023).

Originally assigned to: @gdprdatasubect on GitHub.

NetBox version

v3.4.7

Python version

3.8

Steps to Reproduce

  1. Create an object where the name contains UTF8-Characters (E.g. a device containing é )
  2. Create a custom Export templates that accesses said object names (E.g.: {%for device in queryset%}{{device.name}}{%endfor%}
  3. Use the Export template on previously created objects

Expected Behavior

Same as with "Current View" and "All Data (CSV)", there it works just fine:
grafik

Observed Behavior

grafik
Characters get mangled up

Originally created by @gdprdatasubect on GitHub (Mar 30, 2023). Originally assigned to: @gdprdatasubect on GitHub. ### NetBox version v3.4.7 ### Python version 3.8 ### Steps to Reproduce 1. Create an object where the name contains UTF8-Characters (E.g. a device containing é ) 2. Create a custom Export templates that accesses said object names (E.g.: `{%for device in queryset%}{{device.name}}{%endfor%} ` 3. Use the Export template on previously created objects ### Expected Behavior Same as with "Current View" and "All Data (CSV)", there it works just fine: ![grafik](https://user-images.githubusercontent.com/101808236/228752851-a76b31c3-22af-43a4-ac75-f71f2c88101d.png) ### Observed Behavior ![grafik](https://user-images.githubusercontent.com/101808236/228752734-b7b39be5-054c-4542-9620-9e29ea0dd9bf.png) Characters get mangled up
adam added the status: acceptedtype: feature labels 2025-12-29 20:28:31 +01:00
adam closed this issue 2025-12-29 20:28:31 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 30, 2023):

This doesn't happen for me; the content comes through as expected. However I suspect this is occurring because the default MIME type for an export template is text/plain. Try setting this to text/plain; charset=utf-8 in your export template.

@jeremystretch commented on GitHub (Mar 30, 2023): This doesn't happen for me; the content comes through as expected. However I suspect this is occurring because the default MIME type for an export template is `text/plain`. Try setting this to `text/plain; charset=utf-8` in your export template.
Author
Owner

@gdprdatasubect commented on GitHub (Mar 30, 2023):

Yes, selecting the charset explicitly helped, thanks :)
Should this maybe set as default value?
I can also offer to clarify the documentation if you want…

@gdprdatasubect commented on GitHub (Mar 30, 2023): Yes, selecting the charset explicitly helped, thanks :) Should this maybe set as default value? I can also offer to clarify the documentation if you want…
Author
Owner

@jeremystretch commented on GitHub (Mar 30, 2023):

I can't think of a reason not to change the default MIME type to text/plain; charset=utf-8.

@jeremystretch commented on GitHub (Mar 30, 2023): I can't think of a reason _not_ to change the default MIME type to `text/plain; charset=utf-8`.
Author
Owner

@gdprdatasubect commented on GitHub (Mar 30, 2023):

Can you assign me to this? Then i could add a pull request to change netbox/extras/models/models.py

@gdprdatasubect commented on GitHub (Mar 30, 2023): Can you assign me to this? Then i could add a pull request to change `netbox/extras/models/models.py`
Author
Owner

@jeremystretch commented on GitHub (Mar 30, 2023):

Thanks @gdprdatasubect! I've reclassified this as an enhancement just because I think it's slightly more accurate relative to existing behavior, though admittedly it's a gray area.

@jeremystretch commented on GitHub (Mar 30, 2023): Thanks @gdprdatasubect! I've reclassified this as an enhancement just because I think it's _slightly_ more accurate relative to existing behavior, though admittedly it's a gray area.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7812