4👍
✅
You should use the specific
attribute to get the most specific subclassed form of each page:
Also, there’s a specific()
method on PageQuerySet
which can also be called to retrieve the specific version of all Pages in that queryset.
Finally, notice that calling specific
on a page or queryset will result to an extra query so try to group all specific
calls together. For example, instead of doing:
for page in pages: specific_page = page.specific # This will result to N extra queries (!) # do something with specific_page
do a
for specigic_page in pages.specific(): # 1 extra query for each page subclass # do something with specific_page
Source:stackexchange.com