Django - (1366, "incorrect String Value:... Error
I am getting the following error when I try to add a new record via django admin: OperationalError at /admin/competition/sport/add/ (1366, 'Incorrect string value: '\xC4\x9F\xC3
Solution 1:
You have to modify the django_admin_log character set
ALTERTABLE django_admin_log CHANGE object_repr object_repr VARCHAR(191) CHARACTERSET utf8mb4 COLLATE utf8mb4_unicode_ci;
Solution 2:
classEmployee(models.Model):
name = models.CharField(max_length=100)
defsave(self, *args, **kwargs):
super(Employee, self).save(*args, **kwargs)
self.name = str(self.name.encode('unicode_escape'))
you need to encode with unicode_escape before saving as mention in above example (self.name = str(self.name.encode('unicode_escape'))), no need to do any other setting or db changes
Post a Comment for "Django - (1366, "incorrect String Value:... Error"