。
在调试模式下显示完整的回溯:
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)
答案 0 :(得分:5)
这似乎是Python 2.7 mimetypes.py中的一个问题。请看以下讨论主题:
http://groups.google.com/group/django-users/browse_thread/thread/613909b35a7462a0
有一篇俄语文章的链接,上面写着google-translated:
标准库的存在 源Python - 并允许我们找到 问题很快。 Windows XP。我在用 Windows XP。 [HKEY_CLASSES_ROOT \ CLSID {4063BE15-3B08-470D-A0D5-B37161CFFD69} \ EnableFullPage \ MIME] 在我的情况下 问题是在注册表下 [HKEY_CLASSES_ROOT \ CLSID \ {4063BE15-3B08-470D-A0D5-B37161CFFD69} \ EnableFullPage \ MIME]包含 包含名称的小节 西里尔字母。如果删除这些 键,它们是自动的 重新创建。因此有帮助 重命名,只是取代了西里尔文 拉丁文字母。