X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/9a938c8b406ce05e3bca4a5a483d473ece9e17b0..2caf7411aec24c9dda2a166d777010adb5130f9d:/src/picture/models.py?ds=sidebyside 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')