KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
My Django View/Template is not able to handle special characters. The simple view below fails because of the ñ. I get below error: Non-ASCII character '\xf1' in file" def test(request): return HttpResponse('español') Is there some general setting that I need to set? It would be weird if I had to handle all strings separately: non-American letters are pretty common! EDIT This is in response to the comments below. It still fails :( I added the coding comment to my view and the meta info to my html, as suggested by Gabi. Now my example above doesn't give an error, but the ñ is displayed incorrectly. I tried return render_to_response('tube/mysite.html', {"s": 'español'}) . No error, but it doesn't dislay (it does if s = hello). The other information on the html page displays fine. I tried hardcoding 'español' into my HTML and that fails: UnicodeDecodeError 'utf8' codec can't decode byte 0xf. I tried with the u in front of the string: SyntaxError (unicode error) 'utf8' codec can't decode byte 0xf1 Does this help at all??
Tags (comma-separated)
Save Edits
Cancel