[Fixed]-UnicodeEncodeError while accessing db in django admin

1👍

If you are using @python_2_unicode_compatible, then your __str__ method should return a unicode string.

You havee str(self.region+", "+self.country), which tries to convert the unicode string to a byte string in Python 2. To fix the problem, change the method to:

def __str__(self):
    return self.region + u"," + self.country

Leave a comment