published by | Adam Johnson |
---|---|
in blog | Adam Johnson |
original entry | Django: split ModelAdmin.get_queryset() by view |
Within Django’s popular admin site, you can override ModelAdmin.get_queryset()
to customize the queryset used by the admin views.
It’s often used for performance optimizations, such as adding a select_related()
call to batch-fetch related objects:
from django.contrib import admin
from example.models import Book
@admin.register(Book …