I am migrating project from django 1.11 to django 2 and have the following problem. After migration from python 2.7 to python 3.6 on django 1.11 there are a lot of UnicodeDecodeError's
when im trying to get some data by the ORM. For example:
class JournalName(models.Model):
id = models.AutoField(primary_key=True)
par_id = models.ForeignKey('Journal', db_column='par_id')
parent = models.CharField(max_length=255)
name = models.TextField(blank=True, db_column=u'name')
lang = models.CharField(max_length=10, blank=True)
class Meta:
db_table = 'journal_name'
def __str__(self):
return self.name
following print :
print(JournalName.objects.all())
results with error:
UnicodeEncodeError: 'ascii' codec can't encode character '\u0142' in position 768: ordinal not in range(128)
Project is using MySQL database with utf8. I was trying to debug this but i have no idea what could cause the problem. On python 2.7 everything works ok so maybe there is something left in code that i should change compared to py2? I had to delete some option in db settings which caused other errors but maybe it has something with this:
'OPTIONS': {
"init_command": "set names latin1;",
}