我试图在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