I have created an object Location: class Location(models.Model): city = models.CharField(max_length=50) state = models.CharField(max_length=50) ... But I can't initialize it with either unicode data or utf-8 data. I created a record by hand in my postgresql database. I can now read it using django Location.objects.get function. Then I tried to create a similar record in my database with Django. But I got:
location2 = Location.objects.get(pk=2) print city,state,country 北京 北京 中国 city = location2.city state = location2.state country = location2.country l = Location(city=city, state=state,country=country, district='') Traceback (most recent call last): File "<console>", line 1, in <module> File "/usr/lib/pymodules/python2.5/django/db/models/base.py", line 303, in __init__ val = kwargs.pop(field.attname, field.get_default()) File "/usr/lib/pymodules/python2.5/django/db/models/fields/ __init__.py", line 245, in get_default return force_unicode(self.default, strings_only=True) File "/usr/lib/pymodules/python2.5/django/utils/encoding.py", line 92, in force_unicode raise DjangoUnicodeDecodeError(s, *e.args) DjangoUnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128). You passed in <django.utils.functional.__proxy__ object at 0x99d736c> (<class 'django.utils.functional.__proxy__'>)
-- 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.