+ books = books.only('slug', 'title', 'cover', 'cover_thumb')
+ for category in book_tag_categories:
+ books = books.prefetch_related(
+ Prefetch(
+ 'tag_relations',
+ queryset=TagRelation.objects.filter(tag__category=category)
+ .select_related('tag').only('tag__name_pl', 'object_id'),
+ to_attr='%s_relations' % category))