# HG changeset patch # User neko259 # Date 2017-12-15 10:35:34 # Node ID 7718438668e3d63c52ed968ca5482ddbfa543c60 # Parent 8dd0fa08fa4fa50df8a4adb8844097ac911d4d9a Properly handle tag without aliases (though don't know how this can happen) diff --git a/boards/models/tag.py b/boards/models/tag.py --- a/boards/models/tag.py +++ b/boards/models/tag.py @@ -89,7 +89,17 @@ class Tag(models.Model, Viewable): blank=True, related_name='children') def get_name(self): - return self.aliases.get(locale=DEFAULT_LOCALE).name + try: + alias = self.aliases.get(locale=DEFAULT_LOCALE) + except TagAlias.DoesNotExist: + alias = self.aliases.first() + + if alias: + return alias.name + else: + # This is an extremely bad situation, somehow we have a tag without + # any alias + return 'BROKEN #{}'.format(self.id) def __str__(self): return self.get_name()