X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/acf3c41fb0ffe8e451b1e465b00e9998f2b027ac..98991aa87cc8c4c3377247afc007823124cdc658:/src/catalogue/views.py?ds=inline diff --git a/src/catalogue/views.py b/src/catalogue/views.py index 0b29b6f4..792ea700 100644 --- a/src/catalogue/views.py +++ b/src/catalogue/views.py @@ -12,13 +12,8 @@ class CatalogueView(TemplateView): def get_context_data(self): ctx = super().get_context_data() - documents_books_queryset = models.Book.objects.prefetch_unrelated( - "document_books", "slug", documents.models.Book, "dc_slug" - ) - ctx["authors"] = models.Author.objects.all().prefetch_related( - Prefetch("book_set", queryset=documents_books_queryset), - Prefetch("translated_book_set", queryset=documents_books_queryset), - ) + ctx["authors"] = models.Author.objects.all().prefetch_related('book_set__book_set', 'translated_book_set__book_set') + return ctx @@ -28,12 +23,9 @@ class AuthorView(TemplateView): def get_context_data(self, slug): ctx = super().get_context_data() - documents_books_queryset = models.Book.objects.prefetch_unrelated( - "document_books", "slug", documents.models.Book, "dc_slug" - ) authors = models.Author.objects.filter(slug=slug).prefetch_related( - Prefetch("book_set", queryset=documents_books_queryset), - Prefetch("translated_book_set", queryset=documents_books_queryset), + Prefetch("book_set"), + Prefetch("translated_book_set"), ) ctx["author"] = authors.first() return ctx