Monday, July 31, 2017

Django tutorial part 4: 'utf8' codec can't decode byte 0xa0 in position 22431

Hi everyone, 

I am a Django newbie and started the Tutorial. I followed all steps so far but I am stuck at the part 4. 
So far I've written 3 templates. 

1. file:///C:/Python27/Django/mysite/polls/templates/polls/detail.html

<h1>{question.question_text }}</h1>

 

{% if error_message %}<p><strong>{error_message }}</strong></p>{% endif %}

 

<form action="{% url 'polls:vote' question.id %}" method="post">

{% csrf_token %}

{% for choice in question.choice_set.all %}

    <input type="radio" name="choice" id="choice{forloop.counter }}" value="{{ choice.id }}" />

    <label for="choice{forloop.counter }}">{{ choice.choice_text }}</label><br />

{% endfor %}

<input type="submit" value="Vote" />

<

/form>


2. file:///C:/Python27/Django/mysite/polls/templates/polls/index.html


{% if latest_question_list %}

    <ul>

    {% for question in latest_question_list %}

        <li><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li>

    {% endfor %}

    </ul>

{% else %}

    <p>No polls are available.</p>

{% endif %}


 3. file:///C:/Python27/Django/mysite/polls/templates/polls/results.html


<h1>{question.question_text }}</h1>

 

<ul>

{% for choice in question.choice_set.all %}

    <li>{{ choice.choice_text }} -- {{ choice.votes }} vote{{ choice.votes|pluralize }}</li>

{% endfor %}

</ul>

 

<a href="{% url 'polls:detail' question.id %}">Vote again?</a>



just like explained in the tutorial. 


When I wan to run it on the server I get the error: 



UnicodeDecodeError at /polls/1/

'utf8' codec can't decode byte 0xa0 in position 22431: invalid start byte
Request Method:GET
Request URL:http://127.0.0.1:8000/polls/1/
Django Version:1.11.3
Exception Type:UnicodeDecodeError
Exception Value:
'utf8' codec can't decode byte 0xa0 in position 22431: invalid start byte
Exception Location:C:\Python27\lib\codecs.py in decode, line 314
Python Executable:C:\Python27\python.exe
Python Version:2.7.13
Python Path:
['C:\\Python27\\Django\\mysite',   'C:\\Windows\\system32\\python27.zip',   'C:\\Python27\\DLLs',   'C:\\Python27\\lib',   'C:\\Python27\\lib\\plat-win',   'C:\\Python27\\lib\\lib-tk',   'C:\\Python27',   'C:\\Python27\\lib\\site-packages']
Server time:Tue, 1 Aug 2017 16:03:11 +1000

Unicode error hint

The string that could not be encoded/decoded was: yes'>��� </


I see the same when I encode my html files with utf-8 in word. 


Unfortunately I don't know how to fix this. I've read many threats but none of them really helped me to solve this issue.

Has anyone experienced a similar problem and can help me? 



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4360a617-289d-4e4c-8f60-b7dda65e1fda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment