开发者

django: Processing encoded post request

开发者 https://www.devze.com 2022-12-20 17:19 出处:网络
I am sending POST request from client to the application. On the server side it processed this way: def report(request):

I am sending POST request from client to the application. On the server side it processed this way:

def report(request):

if request.method == "POST":
    dict = request.POST
    idea = dict["idea"]
    print idea
    return HttpResponse("Success")

If idea = "binding" (or any English word) I get http 200 OK

but 开发者_开发百科on the other hand if idea = "связка" (Russian word), I am getting 500 Error

Could you please suggest a way to fix the issue?


Example of post dictionary:

<QueryDict: {u'tournament': [u''], u'sidetomove': [u'true'], 
u'idea': [u'\u0441\u0432\u044f\u0437\u043a\u0430']}>


You are getting an error while printing idea. Try this:

print repr(idea)

This is most probably because of a UnicodeDecodeError.

0

精彩评论

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

关注公众号