Incorrect string value (Exception Value: Incorrect string value: '\xEA\xB0\x95\xED\x95\x98...' for column 'object_repr' at row 1)
Django と MySQL で Unicode 文字列 (韓国語) を保存しようとするとエラーが発生します。最初の問題は、データベース テーブルの各列の「文字列値が正しくありません」というエラーでした。ただし、列の照合順序とデータベース全体の文字セットを変更することで、これを理解しました。
私が得ている新しいエラーは、models.py のunicode (self) メソッドに関連しています。私の models.py は次のとおりです。
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
__unicode__
関数がutf8文字を出力しようとすると、エラーが生成されます...
このエラーを修正する方法を知っている人はいますか?