django URL reverse: When URL reversig a username it fails when username has a '.' literal in it
I didn't expect this to occur [since I didn't know when django changed to allow _ and . in usernames], but when I attempt {% url feed_user entry.username %}
I will get a 500 error when the username contains a '.'开发者_如何学编程 In this case rob.e as a username will fail.
Any ideas how to deal with this?
The problem will be in whatever regex you are using in your urls.py to match feed_user
. Presumably you are using something like r'(?P<username>\w+)/$'
, which only matches on alphanumeric characters and doesn't match on punctuation.
Instead, use this: r'(?P<username>[\w.]+)/$'
精彩评论