我試圖在Django和MySQL中保存unicode字符串(韓語)時出現Incorrect string value (Exception Value: Incorrect string value: '\xEA\xB0\x95\xED\x95\x98...' for column 'object_repr' at row 1)
錯誤。我遇到的第一個問題是數據庫表中每列的「錯誤字符串值」錯誤。但是,我通過更改列整理和整體數據庫字符集來解決這個問題。Django和MySQL的Unicode錯誤
新的錯誤我收到有關的Unicode(個體經營)方法models.py.My models.py是因爲以下幾點:__unicode__
功能的嘗試時產生
from django.db import models
# Create your models here.
class User(models.Model):
full_name = models.CharField(max_length=60)
email = models.EmailField(unique=True)
password = models.CharField(max_length=128)
birthday = models.DateField(null=True, blank=True)
gender = models.PositiveIntegerField(null=True, blank=True)
location = models.CharField(max_length=60, null=True, blank=True)
captcha = models.CharField(max_length=60, null=True, blank=True)
register_date = models.DateTimeField()
lastLogin_date = models.DateTimeField(null=True)
num_logins = models.PositiveIntegerField()
def __unicode__(self):
return self.full_name
錯誤輸出utf8字符...
有沒有人知道如何解決這個錯誤?
您是否嘗試將'smart_unicode'實用程序應用於'self.full_name'(https://docs.djangoproject.com/zh/dev/ref/unicode/#conversion-functions)? – jdi 2012-07-16 05:34:02