Friday, August 2, 2013

Re: Error UnicodeDecodeError when access http://127.0.0.1:8000/admin/

On 3/08/2013 2:44am, Hoàng Trần wrote:
> Hi everybody,
>
> I am very new to Django.
>
> I've just installed it and walked
> through https://docs.djangoproject.com/en/1.5/intro/tutorial01/
>
> My environment is: windows 7 / Python 2.6.6 / Django 1.5.1 / MySQL 5.5.27
>
> I've finished the 01 tutorial, and intend to follow tutorial 02 at here:
> https://docs.djangoproject.com/en/1.5/intro/tutorial02/
>
> But i dont understand when i access: 127.0.0.1:8000/admin i encountered
> with the error:
>
> UnicodeDecodeError at /admin/
> 'utf8' codec can't decode byte 0xb8 in position 174552: invalid
> start byte
>

I don't know the answer. I think Python 2.6.6 believes the byte in
position 174552 is unicode encoded as utf8 but in fact it isn't.

Do you know which file was involved? Perhaps the full traceback will
have a clue?

The first thing I would do is upgrade to Python 2.7.5. After doing that
I would put the following two lines at the top of all my own python .py
files ...

from __future__ import unicode_literals
# -*- coding: utf-8 -*-

... I have no idea if that will work but I believe it persuades Python
to treat everything as unicode.

You don't mention which editor you are using.

You could try downloading/using Notepad++ which has an encoding tool. It
will tell you what the encoding actually is for the file which was
involved. You can then select utf8 and save to change it.



> I've searched over internet but seem not found any solution.
>
> I think Django is very interesting and really want to learn it.
>
> But anyone can help me to pass this situation ?
>
> P/S: When searching over internet, some pages tell me that maybe
> problems because of BOM in the files i edited. So i tried to open every
> .py files in my project by using DOS EDIT. But i can not find any file
> with strange characters in first line. Still don't know what to do.
>
> --
> 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 http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
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 http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate