from catalogue.forms import BookImportForm
from catalogue.models import Book, Tag, BookMedia, Fragment, Collection
+from catalogue.models.tag import prefetch_relations
from picture.models import Picture
from picture.forms import PictureImportForm
if daisy:
books = books.filter(media__type='daisy').distinct()
- if books.exists():
+ books = books.only('slug', 'title', 'cover', 'cover_thumb')
+ for category in book_tag_categories:
+ books = prefetch_relations(books, category)
+ if books:
return books
else:
return rc.NOT_FOUND
def _tag_getter(category):
@classmethod
def get_tag(cls, book):
- return ', '.join(tag.name for tag in book.tags.filter(category=category))
+ return book.tag_unicode(category)
return get_tag