krzyhub
krzyhub

Reputation: 6540

Simple question about characters in django urls

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 domains. 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?

Upvotes: 2

Views: 478

Answers (2)

Arcturus
Arcturus

Reputation: 548

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.

Upvotes: 1

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798456

Yes, but so what. Python supports Punycode natively.

>>> 'xn--' + u'たとえば'.encode('punycode') + '.com'
'xn--r8j2b1a7a.com'

Upvotes: 2

Related Questions