Noob » Tutorial » UnicodeDecodeError in ‘basehtt p.py’
Hi, Django People! It's my second day of getting Django basics so I'm just following the Tutorial precisely. When I first got to the admin site I noticed that it looks odd like the page has lost it's CSS. So I tried to load the CSS file mentioned in the header: http://127.0.0.1:8000/media/css/base.css . What I saw was a Python Traceback cited at the and of this post. Can you tell me what could be the cause of this problem and what should be done to solve it? I'm running Django 1.2.3 and Python 2.7 on Windows(sorry) XP system. The system language is English but my native language is Russian so it can be mentioned somewhere in the system registry and may cause some non-ASCII characters appearance in random places. Traceback (most recent call last): File "C:\progs\Python27\lib\site-packages\django\core\servers \basehttp.py", line 280, in run self.result = application(self.environ, self.start_response) File "C:\progs\Python27\lib\site-packages\django\core\servers \basehttp.py", line 709, in __call__ mime_type = mimetypes.guess_type(file_path)[0] File "C:\progs\Python27\lib\mimetypes.py", line 294, in guess_type init() File "C:\progs\Python27\lib\mimetypes.py", line 355, in init db.read_windows_registry() File "C:\progs\Python27\lib\mimetypes.py", line 260, in read_windows_registry for ctype in enum_types(mimedb): File "C:\progs\Python27\lib\mimetypes.py", line 250, in enum_types ctype = ctype.encode(default_encoding) # omit in 3.x! UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Noob » Tutorial » UnicodeDecodeError in ‘bas ehttp.py’
For people who might have the mentioned problem here is a simple solution (at least a workaround): rename non-ASCII keys from the registry path "HKEY_CLASSES_ROOT\MIME\Database\Content Type" (in my case there were three of them starting with "аудио" and "видео"). Source of solution (in Russian): http://victor-k-development.blogspot.com/2010/07/unicodedecodeerror-django.html P.S. This seams to be a problem of Python 2.7. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Noob » Tutorial » UnicodeDecodeError in ‘bas ehttp.py’
Sandro, it's obviously a good thing to do when using non-ASCII characters *in your code*. The problem is that this exception on my system showed up whenever the mimetypes.guess_type method was called, even if it is the only line of cod in source file (except the import line) and there are no non-ASCII characters in it. P.S. As I've said before this problem turned out to belong to Python's library itself and has nothing to do with Django. On Oct 21, 3:59 pm, Sandro Dutra wrote: > To use unicode characters, I put on the top of source file: -*- coding: > utf-8 -*- and before any string I put an "u", like: u"My unicode string". On > templates, I save the file as utf-8. > > There's no workaround, only code. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.