Ask Your Question

UnicodeEncodeError at /questions/ask/

asked 2013-09-10 10:28:45 -0500

idavydov gravatar image

Hello, I am using most recent version of askbot from github (askbot-devel). When I am trying to create a new question with unicode letters in title I get following error:

UnicodeEncodeError at /questions/ask/
'ascii' codec can't encode characters in position 3-5: ordinal not in range(128)


Request Method: POST
Request URL: http://.../questions/ask/

Django Version: 1.5.2
Python Version: 2.7.3
Installed Applications:
Installed Middleware:

File "/home/dev/askbot/env/local/lib/python2.7/site-packages/django/core/handlers/" in get_response
  115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/dev/askbot/env/local/lib/python2.7/site-packages/django/utils/" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/home/dev/askbot/env/src/askbot/askbot/utils/" in wrapper
  136.             return view_func(request, *args, **kwargs)
File "/home/dev/askbot/env/src/askbot/askbot/utils/" in wrapper
  231.             return view_func(request, *args, **kwargs)
File "/home/dev/askbot/env/src/askbot/askbot/views/" in ask
  259.                         language=language
File "/home/dev/askbot/env/src/askbot/askbot/models/" in user_post_question
  1759.                                     language=language
File "/home/dev/askbot/env/src/askbot/askbot/models/" in create_new
  172.         parse_results = question.parse_and_save(author=author, is_private=is_private)
File "/home/dev/askbot/env/src/askbot/askbot/models/" in parse_and_save
  507.         data = self.parse_post_text()
File "/home/dev/askbot/env/src/askbot/askbot/models/" in parse_post_text
  439.         text = text_converter(self.text)
File "/home/dev/askbot/env/src/askbot/askbot/utils/" in markdown_input_converter
  205.     text = urlize_html(text)
File "/home/dev/askbot/env/src/askbot/askbot/utils/" in urlize_html
  70.     soup = BeautifulSoup(html, 'html5lib')
File "/home/dev/askbot/env/local/lib/python2.7/site-packages/bs4/" in __init__
  167.             if os.path.exists(markup):
File "/home/dev/askbot/env/lib/python2.7/" in exists
  18.         os.stat(path)

Exception Type: UnicodeEncodeError at /questions/ask/
Exception Value: 'ascii' codec can't encode characters in position 3-5: ordinal not in range(128)
edit retag flag offensive close merge delete


Is this in the production setup?

Evgeny gravatar imageEvgeny ( 2013-09-23 15:43:28 -0500 )edit

Evgeny, actually I've tried first to install stable version 0.7.43. But python migrate askbot failed on both mysql and postgres. Then I tried git latest version and migrate passed succesfully but I got unicode error.

idavydov gravatar imageidavydov ( 2013-09-24 05:22:26 -0500 )edit

Evgeny, I have the same problem with cyrillic. i.e.: I add simple test question (see screenhot: and get the following result with "UnicodeEncodeError at /questions/ask/" error: I am using the completely new version of Askbot (0.7.49), django 1.5.4 Error appears when I add russian text from keybord to descripton of the question filed or to the answer. Error never apper when I copy-paste russian text from UTF-8 website like That is all quite strange I would be very thankful, if you coul tell what is the reason of it or any idea about this one. (parameter ALLOW_UNICODE_SLUGS is set to True) UPDATED: the reason was - that I used it as gunicorn, when I launched it as runserver - it started to work without any errors

shurikanet gravatar imageshurikanet ( 2013-10-07 02:31:50 -0500 )edit

2 answers

Sort by » oldest newest most voted

answered 2016-12-20 11:29:29 -0500

Evgeny gravatar image

The issue is that the encoding set in your server python process is unable to encode a specific unicode string.

Details can be found here

To solve this, set the following locale related environment variables to be used in your python server process:


For example uwsgi takes the following (in the .ini file):

env = LC_ALL='en_US.UTF-8' #I find this sufficient
edit flag offensive delete link more

answered 2016-12-01 21:08:51 -0500

Tvartom gravatar image

I believe it the cache! For me it started to work when I disabled Memcached!

You can read my answer to my own quiestion here:

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-09-10 10:28:45 -0500

Seen: 1,132 times

Last updated: Dec 20 '16