diff --git a/boards/models/tag.py b/boards/models/tag.py --- a/boards/models/tag.py +++ b/boards/models/tag.py @@ -4,7 +4,7 @@ import re from boards.models.attachment import FILE_TYPES_IMAGE from django.template.loader import render_to_string from django.db import models -from django.db.models import Count +from django.db.models import Count, Q from django.core.urlresolvers import reverse from django.utils.translation import get_language @@ -130,14 +130,19 @@ class Tag(models.Model, Viewable): def get_view(self): locale = get_language() - try: - localized_tag_name = self.aliases.get(locale=locale).name - except TagAlias.DoesNotExist: - localized_tag_name = '' + aliases = self.aliases.filter(Q(locale=locale) | Q(locale=DEFAULT_LOCALE)) + + localized_tag_name = None + default_tag_name = None - default_name = self.get_name() + for alias in aliases: + if alias.locale == locale: + localized_tag_name = alias.name + elif alias.locale == DEFAULT_LOCALE: + default_tag_name = alias.name - name = '{} ({})'.format(default_name, localized_tag_name) if localized_tag_name else default_name + name = '{} ({})'.format(default_tag_name, localized_tag_name) \ + if localized_tag_name else default_tag_name link = '{}'.format( self.get_absolute_url(), name) if self.is_required():