X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/9a938c8b406ce05e3bca4a5a483d473ece9e17b0..ce02a06785b4ef96aa7aebc63641883a9ee491d4:/src/picture/models.py?ds=inline diff --git a/src/picture/models.py b/src/picture/models.py index e10d2faf1..6d8def377 100644 --- a/src/picture/models.py +++ b/src/picture/models.py @@ -12,6 +12,8 @@ from django.core.files.storage import FileSystemStorage from django.utils.datastructures import SortedDict from fnpdjango.utils.text.slughifi import slughifi from ssify import flush_ssi_includes + +from catalogue.models.tag import prefetched_relations from picture import tasks from StringIO import StringIO import jsonfield @@ -128,7 +130,11 @@ class Picture(models.Model): return self.tags.filter(category='author') def tag_unicode(self, category): - return ", ".join(self.tags.filter(category=category).values_list('name', flat=True)) + relations = prefetched_relations(self, category) + if relations: + return ', '.join(rel.tag.name for rel in relations) + else: + return ', '.join(self.tags.filter(category=category).values_list('name', flat=True)) def author_unicode(self): return self.tag_unicode('author')