开发者

Django: # in url as a character?

I've made a Django application that uses tags. When i use tag 'c#' and try to redirect to mysiteaddress/tags/c# on server it redirects to ../tags/c and shows me stuff connected to 'c' tag, but when I do the same on my local development machine it redirects me to c%23 and works correctly. What should I change to mak开发者_如何学JAVAe it work on production server?


Without more code I can't be too specific, but '#' corresponds to the character escape sequence %23 and something in your code may need to explicitly escape 'c#' before putting it in the url.

Here is a django-snippet that uses url-quoting:

http://www.djangosnippets.org/snippets/1159/

The solution to your problem might look like this:

from django.utils.http import urlquote
...
tag = urlquote(tag)
tag_url = base + "tags/" + tag
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜