This site has moved, this is just for reference, please visit the current one.

P Bergqvist

Locale trouble with Django 1.4 on MacOSX

Published: maj 12, 2012

Tags: django macosx

Comments:  

I just upgraded one of my Django projects to 1.4, I deleted the test database and made me a new one, but I ran into some trouble. When creating the superuser something went wrong and it all ended with an exception about some locale.

Traceback:

Traceback (most recent call last):
  .
  .
  File "/Users/peppe/Envs/snippets/lib/python2.7/locale.py", line 428, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

The way around this is to set your locale to something that makes sense. Following the bug report/guide at [https://code.djangoproject.com/ticket/5846] I just ran:

export LC_CTYPE=sv_SE.UTF-8
export LANG=sv_SE.UTF-8
export LC_ALL=sv_SE.UTF-8

in the terminal, and this should work for you if you're just using the standard terminal in MacOSX.

But, since I'm using FISH as shell I had to change to FISH syntax, so this works for me:

set LC_CTYPE sv_SE.UTF-8
set LANG sv_SE.UTF-8
set LC_ALL sv_SE.UTF-8

To not have to run this code every time in every terminal I suggest you add it to ~/.config/fish/config.fish.

Happy upgrading!

blog comments powered by Disqus

Copyright © 2012 Me. All rights reserved.