开发者

After submitting form, the value is different due to encoding? (Python)

I am using Django.

In a regular form, the user enters "Gerry & Pacemakers".

(Notice the Ampersand sign.)

When I go views.py...

def myview(request):
    q = request.GET.get('q','').strip()
    print q

q is "Gerry"...but it's supposed to be "Gerry &开发者_JAVA技巧 Pacemakers"...encoded Is the correct way doing this by using urllib??

How do I encode it BEFORE it hits the view? It's very weird, because the URL contains the encoding: ?q=gerry+%26+pacemakers


Since you are pulling the data from request.GET, it looks like you're building the URL in the browser somehow. You need to use the Javascript escape() function to handle URL-significant characters properly.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜