Thursday, March 3, 2011

Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)

1. web browser does not give messages, in command line I see:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py",
line 280, in run
self.result=application(self.environ, self.start_response)
File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py",
line 709, in __call__
mime_type=mimetypes.guess_type(file_path)[0]
File "C:\Python27\lib\mimetypes.py", line 294, in guess_type
init()
File "C:\Python27\lib\mimetypes.py", line 355, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 259, in
read_windows_registry
for ctype in enum_types(mimedb):
File "C:\Python27\lib\mimetypes.py", line 249, 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)

2. mysite\blog\models.py:
# -*- coding: utf-8 -*-

from django.db import models
from django.contrib import admin

class BlogPost(models.Model):
title = models.CharField(max_length=150)
body = models.TextField()
timestamp = models.DateTimeField()

class Meta:
ordering = ('-timestamp',)

class BlogPostAdmin(admin.ModelAdmin):
list_display = ('title', 'timestamp')

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment