name must be unicode

This commit is contained in:
j 2015-02-03 18:44:05 +01:00
parent c1e49e416f
commit 83393ee385

View file

@ -46,6 +46,8 @@ class Entity(models.Model):
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
entity = get_by_id(settings.CONFIG['entities'], self.type) entity = get_by_id(settings.CONFIG['entities'], self.type)
if entity.get('sortType') == 'person' and self.name: if entity.get('sortType') == 'person' and self.name:
if isinstance(self.name, str):
self.name = self.name.decode('utf-8')
self.name_sort = get_name_sort(self.name)[:255].lower() self.name_sort = get_name_sort(self.name)[:255].lower()
else: else:
self.name_sort = ox.sort_string(self.name or u'')[:255].lower() or None self.name_sort = ox.sort_string(self.name or u'')[:255].lower() or None