BlogPost title with special chars ending in exception

69 views
Skip to first unread message

Pedro Araújo

unread,
Aug 6, 2012, 1:28:24 PM8/6/12
to mezzani...@googlegroups.com
Hi! I'm having the problem reported in https://github.com/stephenmcd/mezzanine/pull/183 with BlogPosts. I create a BlogPost with special characters in the title and it generates a slug with special characters. Mezzanine creates the list of templates to be used by django OK. But when django tries to get the files it fails.

Traceback (most recent call last):

  File "/home/django/novaweb_pt/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 136, in get_response
    response = response.render()

  File "/home/django/novaweb_pt/local/lib/python2.7/site-packages/django/template/response.py", line 104, in render
    self._set_content(self.rendered_content)

  File "/home/django/novaweb_pt/local/lib/python2.7/site-packages/django/template/response.py", line 79, in rendered_content
    template = self.resolve_template(self.template_name)

  File "/home/django/novaweb_pt/local/lib/python2.7/site-packages/django/template/response.py", line 55, in resolve_template
    return loader.select_template(template)

  File "/home/django/novaweb_pt/local/lib/python2.7/site-packages/django/template/loader.py", line 187, in select_template
    return get_template(template_name)

  File "/home/django/novaweb_pt/local/lib/python2.7/site-packages/django/template/loader.py", line 145, in get_template
    template, origin = find_template(template_name)

  File "/home/django/novaweb_pt/local/lib/python2.7/site-packages/django/template/loader.py", line 134, in find_template
    source, display_name = loader(name, dirs)

  File "/home/django/novaweb_pt/local/lib/python2.7/site-packages/django/template/loader.py", line 42, in __call__
    return self.load_template(template_name, template_dirs)

  File "/home/django/novaweb_pt/local/lib/python2.7/site-packages/django/template/loader.py", line 45, in load_template
    source, display_name = self.load_template_source(template_name, template_dirs)

  File "/home/django/novaweb_pt/local/lib/python2.7/site-packages/django/template/loaders/filesystem.py", line 37, in load_template_source
    file = open(filepath)

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe7' in position 89: ordinal not in range(128)


My main question is: Should I open this as a Mezzanine issue or a Django issue (in the django tracker of course)?

Thanks in advance and keep up the great work.

Pedro Araújo

Stephen McDonald

unread,
Aug 6, 2012, 4:53:07 PM8/6/12
to mezzani...@googlegroups.com
Yes please report bugs in the issue tracker, thanks.

As a side note I wasn't able to reproduce this - are you able to do so on the demo site?
--
Stephen McDonald
http://jupo.org

Pedro Araujo

unread,
Aug 6, 2012, 5:40:00 PM8/6/12
to mezzani...@googlegroups.com
Hi! I tried on the demo site but was not able to reproduce. I will figure out the steps needed to cause this and post here. Because this is working in the demo site I will also look into my own server.


Pedro Araújo

Stephen McDonald

unread,
Aug 6, 2012, 7:16:23 PM8/6/12
to mezzani...@googlegroups.com
You might find you need to set your system's locale to handle utf8. Please let us know how you go.

Pedro Araujo

unread,
Aug 7, 2012, 4:08:38 AM8/7/12
to mezzani...@googlegroups.com
This was indeed a misconfiguration in my server. I'll just leave here waht I did to fix this (this was an Ubuntu Server 12.04):

 - apt-get install language-pack-en-base
 - dpkg-reconfigure locales
 - add 'LANG="en_US.UTF-8"' to the file /etc/default/locale

this should make your enviroment ready for UTF-8.

Thanks for your help.

Pedro Araújo
Reply all
Reply to author
Forward
0 new messages