In django documentation they wrote that in urls it is only possible to use ASCII characters. It seems to be strange to me because of characters that are in IDN do开发者_如何学Gomains. For exapmle, if I have IDN domain and I want to have not only ASCII characters in urls, it is really impossible by default to do this in easy way?
Yes, but so what. Python supports Punycode natively.
>>> 'xn--' + u'たとえば'.encode('punycode') + '.com'
'xn--r8j2b1a7a.com'
A simple workaround is to ask Django to match the URL as '.' regexp raw string, since it does not understand '\w' to mean your character set of UTF-8 etc.
So in urls.py you can write 'foo/bar/.+' instead of 'foo/bar/\w+' which is exclusive for English speakers, as it were. I'm just kidding.
Goodluck.
精彩评论