When i'm trying to load http://127.0.0.1:8000/media/javascripts/bg-input.png(This PNG file exists)
I get a 500 http response saying: UnicodeDecodeError at /media/javascripts/bg-input.png 'ascii' codec can't decode byte 0xca in position 0: ordinal not in range(128) Request Method: GET Request URL: http://127.0.0.1:8000/media/javascripts/bg-input.png Django Version: 1.3.1 Exception Type: UnicodeDecodeError Exception Value: 'ascii' codec can't decode byte 0xca in position 0: ordinal not in range(128) Exception Location: T:\Python27\lib\mimetypes.py in enum_types, line 250 Python Executable: T:\Python27\python.exe Python Version: 2.7.0 Python Path: ['T:\\djangos\\deadline', 'T:\\Python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg', 'T:\\Python27\\lib\\site-packages\\django_pagination-1.0.7- py2.7.egg', 'T:\\Python27\\lib\\site-packages\\simplejson-2.3.2-py2.7.egg', 'C:\\Windows\\system32\\python27.zip', 'T:\\Python27\\DLLs', 'T:\\Python27\\lib', 'T:\\Python27\\lib\\plat-win', 'T:\\Python27\\lib\\lib-tk', 'T:\\Python27', 'T:\\Python27\\lib\\site-packages', 'T:\\Python27\\lib\\site-packages\\PIL'] Server time: 星期二, 7 二月 2012 13:33:53 +0800 Unicode error hint The string that could not be encoded/decoded was: ����/x Environment: Request Method: GET Request URL: http://127.0.0.1:8000/media/javascripts/bg-input.png Django Version: 1.3.1 Python Version: 2.7.0 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'pagination', 'deadline.reg', 'deadline.helpers', 'deadline.users', 'deadline.tasks', 'deadline.comments'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfResponseMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'pagination.middleware.PaginationMiddleware') Traceback: File "T:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response 111. response = callback(request, *callback_args, **callback_kwargs) File "T:\Python27\lib\site-packages\django\views\static.py" in serve 54. mimetype, encoding = mimetypes.guess_type(fullpath) File "T:\Python27\lib\mimetypes.py" in guess_type 294. init() File "T:\Python27\lib\mimetypes.py" in init 355. db.read_windows_registry() File "T:\Python27\lib\mimetypes.py" in read_windows_registry 260. for ctype in enum_types(mimedb): File "T:\Python27\lib\mimetypes.py" in enum_types 250. ctype = ctype.encode(default_encoding) # omit in 3.x! Exception Type: UnicodeDecodeError at /media/javascripts/bg-input.png Exception Value: 'ascii' codec can't decode byte 0xca in position 0: ordinal not in range(128) #settings.py ... # Absolute filesystem path to the directory that will hold user- uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = 'T:/djangos/deadline/media/' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://media.lawrence.com/media/", "http://example.com/ media/" MEDIA_URL = '/media/' # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = '' # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = '/static/' .... #urls.py .... url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), .... This problem happens when I am running on windows 7. In ubuntu 11.04 it works fine. Windows 7 version: 7600 Ultimate Django version: 1.3.1 Final A link on stackoverflow http://stackoverflow.com/questions/9171497/fail-to-load-media-files-in-djangoon-windows#comment11560283_9171497 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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.