2👍
✅
You’re probably getting an UnicodeEncodeError because
request.POST.get('location')
returns an unicode object. When you try to print it, Python tries to encode it using the ‘ascii’ codec and fails because it contains non-ascii chars.
If you really want to print it, use:
print request.POST.get('location').encode('utf-8')
EDIT: more info about encodings in Python: https://docs.python.org/2/howto/unicode.html
0👍
Finally, I find a magic way to solve this problem . I just comment the print statement in view. But I’m still not sure for its reason.
- [Django]-TypeError: 'User' object is not subscriptable
- [Django]-How do I call templates with same names at different directories in Django?
- [Django]-Django: How to update related model fields when creating model
- [Django]-Django template: How to use values/values_list
- [Django]-Django: Selenium- stale element reference on browse
Source:stackexchange.com