How to redirect to a query string URL containing non-ascii characters in DJANGO?
When I use "return HttpResponseRedirect(u'/page/?title=' + query_string)" where the query_string contains characters like "你好", I get an error "'ascii' codec can't encode characters in position 21-26: ordinal not in range(128), HTTP response headers must be in US-ASCII format"...
return HttpResponseRedirect(u'/page/?title=' + query_string)
In Django, you can get native support from http.py:
from django.utils.http import urlquote, urlquote_plus
And yes, these functions will invoke urllib package to call quote and quote_plus functions.
What I need is a way to turn a chinese character into the form "&#XXXXX;" but I can't find any documentation of it... anywhere..... edit: found it.... urllib.quote_plus() turns it into %e0 , etc its not the above form, but it's good...
您正在浏览的问题含有以下标签:
django × 15 Python × 12
提问时间: 1 month前
目前浏览数量:150 次
最后更新时间:1 month前
Django的应用趋势?在中国有多少人在用?
How to redirect to a query string URL containing non-ascii characters in Django?
为什么Bluehost的服务器不能正常解析含%23的地址?
Django step by step (三) 报错呢?
有谁知道Django和Joomla的区别?
django中form的ModelChoiceField怎样传值到view里?
Can the CNProg framework be used for a Q&A site in English?
django 如何 port 到 gae?
有python + django开发的sns开源项目吗
本地跑Django脚本解析出错了也一声不坑