Django unsupported locale settings

195 views
Skip to first unread message

Mo Mughrabi

unread,
Jun 5, 2012, 7:06:13 AM6/5/12
to django...@googlegroups.com, Tariq Alabdulmuhsen, Reza Muhammad

I've been developing an application using Django for the past a year. The application was written in a Debian environment, the development and testing was entirely done in a debain machine.

Recently, I decided to move the application to my local Mac OS X based laptop. using port's I did a virtual environment and pulled my project from github. When I try to runserver, am getting "unsupported locale setting" exception.

My application uses locale heavily, I noticed though the language setting in my machine is set for en_US.UTF-8 while on the debian machine it was en_US.UTF8. I don't know if the dash is the reason why it is failing though.

My application is using django-localeurl for creating language code url schema for i10n and i18n.

below is the exception am getting

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/en/

Django Version: 1.3.1
Python Version: 2.7.1
Installed Applications:
['localeurl',
 
'django.contrib.auth',
 
'django.contrib.contenttypes',
 
'django.contrib.sessions',
 
'django.contrib.sites',
 
'django.contrib.messages',
 
'django.contrib.staticfiles',
 
'django.contrib.humanize',
 
'django.contrib.comments',
 
'libraries.plugins.piston',
 
'nani',
 
'haystack',
 
'compressor',
 
'libraries.plugins.social_auth',
 
'registration',
 
'djcelery',
 
'django.contrib.markup',
 
'south',
 
'libraries.plugins.storages',
 
'libraries.plugins.django_messages',
 
'merlin',
 
'seacucumber',
 
'timezones',
 
'treebeard',
 
'apps.core',
 
'apps.core.mediastore',
 
'apps.core.accounts',
 
'apps.core.mazvars',
 
'apps.core.mazguard',
 
'apps.core.system',
 
'apps.core.sponsorship',
 
'apps.portal.default',
 
'apps.portal.support',
 
'apps.portal.pages',
 
'apps.portal.blog',
 
'apps.portal.developer',
 
'apps.listing',
 
'apps.listing.postfix',
 
'apps.listing.category',
 
'apps.listing.post',
 
'apps.listing.home',
 
'apps.listing.shoutout',
 
'apps.listing.taggables',
 
'apps.listing.comment',
 
'apps.listing.badge',
 
'apps.listing.geo',
 
'apps.listing.reputation',
 
'apps.mzn.shorturl',
 
'grappelli.dashboard',
 
'grappelli',
 
'django.contrib.admin',
 
'django.contrib.admindocs',
 
'debug_toolbar']
Installed Middleware:
('localeurl.middleware.LocaleURLMiddleware',
 
'django.middleware.common.CommonMiddleware',
 
'django.contrib.sessions.middleware.SessionMiddleware',
 
'django.middleware.csrf.CsrfViewMiddleware',
 
'django.contrib.auth.middleware.AuthenticationMiddleware',
 
'django.contrib.messages.middleware.MessageMiddleware',
 
'apps.core.middleware.FallbackLocaleMiddleware',
 
'apps.core.accounts.middleware.LoggingMiddleware',
 
'apps.core.accounts.middleware.CompleteEmail',
 
'apps.core.accounts.middleware.setref',
 
'apps.core.accounts.middleware.FollowUser',
 
'apps.core.accounts.middleware.UnFollowUser',
 
'apps.core.accounts.middleware.FraudLocked',
 
'apps.core.middleware.DefaultAdminLocaleMiddleware',
 
'apps.core.middleware.DefaultSiteMiddleware',
 
'debug_toolbar.middleware.DebugToolbarMiddleware')


Traceback:
File "/Users/mo/Projects/pythonic/mazban/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
 
111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Users/mo/Projects/pythonic/mazban/mazban/apps/listing/home/views.py" in home
 
23.     cal = render_event_calendar_widget(language_code=request.LANGUAGE_CODE)
File "/Users/mo/Projects/pythonic/mazban/mazban/apps/listing/post/event_views.py" in render_event_calendar_widget
 
115.     return cal.render()
File "/Users/mo/Projects/pythonic/mazban/mazban/apps/core/utils.py" in render
 
81.             [day for day in cal.formatweekheader(self.wh).split(' ')]
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/calendar.py" in formatweekheader
 
297.         return ' '.join(self.formatweekday(i, width) for i in self.iterweekdays())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/calendar.py" in <genexpr>
 
297.         return ' '.join(self.formatweekday(i, width) for i in self.iterweekdays())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/calendar.py" in formatweekday
 
511.         with TimeEncoding(self.locale) as encoding:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/calendar.py" in __enter__
 
490.         _locale.setlocale(_locale.LC_TIME, self.locale)
File "/Users/mo/Projects/pythonic/mazban/lib/python2.7/locale.py" in setlocale
 
531.     return _setlocale(category, locale)

Exception Type: Error at /
Exception Value: unsupported locale setting


any idea's what could be causing this?

update:

when I logged in to terminal and wrote "locale" I got the below

(mazban)Mohammed-Mughrabis-MacBook-Pro:mazban mo$ locale
LANG
="en_US.UTF-8"
LC_COLLATE
="en_US.UTF-8"
LC_CTYPE
="en_US.UTF-8"
LC_MESSAGES
="en_US.UTF-8"
LC_MONETARY
="en_US.UTF-8"
LC_NUMERIC
="en_US.UTF-8"
LC_TIME
="en_US.UTF-8"
LC_ALL
=

Thanks, 

Thomas Lockhart

unread,
Jun 5, 2012, 9:41:22 AM6/5/12
to django...@googlegroups.com
On 6/5/12 4:06 AM, Mo Mughrabi wrote:

I've been developing an application using Django for the past a year. The application was written in a Debian environment, the development and testing was entirely done in a debain machine.

Recently, I decided to move the application to my local Mac OS X based laptop. using port's I did a virtual environment and pulled my project from github. When I try to runserver, am getting "unsupported locale setting" exception.


Mac-based development is working great for me. But you do have to modify manage.py slightly, and add the following:

os.environ.setdefault(‘LANG’,’en_CA’)

hth

                           - Tom
Reply all
Reply to author
Forward
0 new messages