2

UnicodeDecodeError

Appears while trying to access any of the files from site media folder.

Full traceback presented in debug mode:

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/site-media/img/image.png
Django Version: 1.2.3
Python Version: 2.7.0
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.markup',
 'special']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "C:\Languages\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
  100.                     response = callback(request, *callback_args, **callback_kwargs)
File "C:\Languages\Python27\lib\site-packages\django\views\static.py" in serve
  59.     mimetype = mimetypes.guess_type(fullpath)[0] or 'application/octet-stream'
File "C:\Languages\Python27\lib\mimetypes.py" in guess_type
  294.         init()
File "C:\Languages\Python27\lib\mimetypes.py" in init
  355.             db.read_windows_registry()
File "C:\Languages\Python27\lib\mimetypes.py" in read_windows_registry
  260.             for ctype in enum_types(mimedb):
File "C:\Languages\Python27\lib\mimetypes.py" in enum_types
  250.                     ctype = ctype.encode(default_encoding) # omit in 3.x!

Exception Type: UnicodeDecodeError at /site-media/img/image.png
Exception Value: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)
1
  • 1
    Have you configured your urls.py file to serve static media? Commented Nov 18, 2010 at 12:42

1 Answer 1

5

It seems to be a problem in Python 2.7 mimetypes.py. Look at the following discussion thread:

http://groups.google.com/group/django-users/browse_thread/thread/613909b35a7462a0

There is a link to a russian article which says when google-translated:

The presence of the standard library source Python-and allowed us to find the problem pretty quickly. Windows XP. I am using Windows XP. [HKEY_CLASSES_ROOT\CLSID{4063BE15-3B08-470D-A0D5-B37161CFFD69}\EnableFullPage\MIME] In my case the problem was that in the registry under [HKEY_CLASSES_ROOT \ CLSID \ {4063BE15-3B08-470D-A0D5-B37161CFFD69} \ EnableFullPage \ MIME] contain subsections containing the name of the Cyrillic alphabet. If you delete these keys, they are automatically re-create. Therefore helped to rename, just replaced the Cyrillic alphabet in Latin.

Here is the article: http://translate.google.fr/translate?js=n&prev=_t&hl=fr&ie=UTF-8&layout=2&eotf=1&sl=ru&tl=en&u=http%3A%2F%2Fvictor-k-development.blogspot.com%2F2010%2F07%2Funicodedecodeerror-django.html

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry I'm late on approval. You was very helpful. And since I'm russian I had no trouble getting this fixed. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.