.
This commit is contained in:
+10
-3
@@ -22,12 +22,17 @@ from easy_thumbnails.files import get_thumbnailer
|
||||
|
||||
from easy_thumbnails.exceptions import InvalidImageFormatError
|
||||
|
||||
|
||||
|
||||
from django.db.models import Prefetch
|
||||
|
||||
|
||||
class CaseTable(tables.Table):
|
||||
def __init__(self, data=None, *args, **kwargs):
|
||||
# Optimize prefetching for casecollection_set
|
||||
#case_collections_prefetch = Prefetch(
|
||||
# "casecollection_set",
|
||||
# queryset=CaseCollection.objects.select_related("author"), # Adjust fields as needed
|
||||
#)
|
||||
|
||||
super().__init__(
|
||||
data.prefetch_related(
|
||||
"author", # Many-to-many or reverse relationship
|
||||
@@ -36,7 +41,9 @@ class CaseTable(tables.Table):
|
||||
"series__plane", # ForeignKey in the related model
|
||||
"series__images", # Reverse relationship
|
||||
"previous_case", # Prefetch the previous case relationship
|
||||
#"next_case", # Prefetch the next case relationship
|
||||
"next_case", # Prefetch the next case relationship
|
||||
"casecollection_set", # Prefetch the case collection set
|
||||
#case_collections_prefetch, # Optimized prefetch for collections
|
||||
),
|
||||
*args,
|
||||
**kwargs,
|
||||
|
||||
Reference in New Issue
Block a user