Django - writing an hebrew string

559 views Asked by At

I'm trying to send an hebrew string through parse rest API in a Django code the code is fine - sending a string in english works perfectly when the letters are in hebrew I get the following error:

Non-ASCII character '\xd7' but no encoding declared;

how can I set encoding programmatically for a specific line?

1

There are 1 answers

0
arie On BEST ANSWER

It's explained in the docs:

Python supports writing Unicode literals in any encoding, but you have to declare the encoding being used. This is done by including a special comment as either the first or second line of the source file

In your case:

# -*- coding: utf-8 -*-