Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

have unicode characters in url

Tags:

python

django

for example in this url:

(r'^company/لیست-مقالات/$','CompanyHub.views.docList')

in لیست مقالات part I have unicode characters but I get this error:

Caught UnicodeDecodeError while rendering: 'ascii' codec can't decode byte 0xd9 in position 0: ordinal not in range(128)
like image 816
Asma Gheisari Avatar asked Mar 14 '26 13:03

Asma Gheisari


1 Answers

You need to put a u in front of r before the string, or wrap it in the unicode method:

See this for more info.

Unicode strings are much like strings, but are specified in the syntax using a preceding 'u' character: u'abc', u"def".

http://docs.python.org/library/stdtypes.html

like image 161
Alex W Avatar answered Mar 17 '26 02:03

Alex W



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!