» Locale on django and uwsgi UnicodeEncodeError
Locale on django and uwsgi UnicodeEncodeError
|July 22, 2014
Posted by forumadmin
EDIT: I just realized, that when i’m not trying to print to console that variable, it works. Why?
I run into an issue related to displaying string label with utf chars. I set locale env in uwsgi ini file like this:
and in wsgi.py:
When I run app code:
print (locale.getlocale(), locale.getpreferredencoding())
print "option_value", option_value
label = force_text(option_label)
print 'label', label #THIS FAILS
the output is:
(('en_US', 'UTF-8'), 'UTF-8')
ERROR <stack trace>
print 'label', label
UnicodeEncodeError: 'ascii' codec can't encode character u'\u015b' in position 5: ordinal not in range(128)
The problem is not present when I run app via runserver in production environment.
Django 1.6.5 Python 2.7.6 Ubuntu 14.04 uWSGI 22.214.171.124
More Related Questions
- Prevent Django from blocking while proxying an HTTP request I'm working on a Django site that allows connecting to devices in restricted networks through a cloud service. The devices connect to a cloud server through a VPN or SSH tunnel and clients […]
- What is the difference between mod_wsgi and uwsgi? There seems to be mod_wsgi module in Apache and uwsgi module in Nginx. And there also seems to be the wsgi protocol and uwsgi protocol.
I have the following questions.
Are mod_wsgi and […]
- What is the correct way to set Pythons locale? I'm attempting to sort a list of strings in a locale-aware manner. I've used the Babel library for other i18n-related tasks, but it doesn't support sorting. Python's locale module […]
- Bad File descriptor with uWSGI native async websockets and redis Hi I have a simple websocket server which is pushing messages to clients, the code is as follows
uwsgi.websocket_handshake(env['HTTP_SEC_WEBSOCKET_KEY'], env.get('HTTP_ORIGIN', ''))
- Localization and future-proofing so I know this is a not a good question for the StackOverflow format. but I am at a bit of a loss, feel free to recommend a different place to put this where it may get some eyeballs
- No module named pkg_resources I'm deploying a Django app to a dev server and am hitting this error when i run pip install requirements.txt:
Traceback (most recent call last):
- Core Dump Segfault While Executing An Example of scikits.cuda in Django I tried to run following simple cublas example on both console environment and in Django framework.
Demonstrates multiplication of two matrices on the GPU.
- False 404 from Django test? I'm having trouble with testing my Django app. I can load a page in the browser just fine, but my test code returns 404.
This test returns False:
response = […]
- Restarting a Django application running on Apache + mod_python I'm running a Django app on Apache + mod_python. When I make some changes to the code, sometimes they have effect immediately, other times they don't, until I restart Apache. However I […]
- Getting "Error loading MySQLdb module: No module named MySQLdb" – have tried previously posted solutions This is a much discussed issue for OSX 10.6 users, but I haven't been able to find a solution that works. Here's my setup:
Python 2.6.1 64bit
MySQL 5.1.47 osx10.6 64bit