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

CSV Export generate an UnicodeEncodeError if verbose_name use non ascii characters #12

Closed
yvguim opened this issue Mar 12, 2013 · 2 comments

Comments

@yvguim
Copy link

yvguim commented Mar 12, 2013

Hi,
I play with django-adminactions and it's really a nice job, thanks!

However for an application with french translation, CSV Export raise a UnicodeEncodeError if verbose_name_plural use non ascii characters.


Django Version: 1.4.3
Exception Type: UnicodeEncodeError
Exception Value:

'ascii' codec can't encode character u'\xe8' in position 25: ordinal not in range(128), HTTP response headers must be in US-ASCII format

The problem is located at this line in export.py
:
filename = "%s.csv" % queryset.model.meta.verbose_name_plural.lower().replace(" ", "")

I fix it for my app by using a generic filename for exports.

@saxix
Copy link
Owner

saxix commented Mar 13, 2013

thanks for the ticket.
Please check last commit, just added utility callback get__filename() handler. If the ModelAdmin has this attribute it is called (passing request and queryset) to get the filename. Otherwise each not valid char in verbose_name is substituted by '?'

@saxix saxix closed this as completed Mar 13, 2013
@yvguim
Copy link
Author

yvguim commented Mar 13, 2013

thanks for your commit, I have tested both case with success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants