2

Sometimes I m getting unicode errors like below in my django site when user submit form data.

"'ascii' codec can't encode character u'\u2014' in position 109: ordinal not in range(128)"

How can i reproduce the unicode error in my system

Many Thanks.

2 Answers 2

5

Submit the form causing the errors with unicode characters (e.g.é) in it!

This is a very common error in Django projects and it almost always means you are calling str() somewhere. Django uses unicode strings internally but when you call str() you are asking Python to give you an ascii string back, which fails with this message.

If you give us more info, we'll be able to help you further.

Good luck!

Sign up to request clarification or add additional context in comments.

1 Comment

Or, alternatively, you're (implicitly) returning str inside a __unicode__ method.
2

Have you left any debug prints in your view? That will cause a conversion to the console's encoding, which may be ascii causing this error.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.