Django - Url Pattern Regex Not Matching String Parameter With Accents
I'm having some trouble passing string arguments with accents to my Django application. I have the following url pattern: url(r'^galeria/(?P\d+)/(?P\w+)/(?
Solution 1:
Use %c3%a9
instead of %e9
in the URL. The regex isn't failing... Django isn't even getting to the urlconf. Check the logs, you're probably getting 400 errors.
URI paths should contain UTF-8-encoded characters only. Any UTF-8 character that cannot be represented as a normal, printable ASCII character (and is not on the reserved list) should be percent-encoded.
é
(U+00E9) is a multibyte character in UTF-8: 0xc3a9
. The percent-encoded form would be %C3%A9
. The single byte 0xe9 is NOT a valid UTF-8 character.
See RFC 3986.
[\w|\W]+
successfully matches URLs containing %C3%A9
. Django appears to percent-decode the URL byte string into a Unicode string, then converts it to UTF-8 for urlconf matching.
Post a Comment for "Django - Url Pattern Regex Not Matching String Parameter With Accents"