I have run into a situation where the mass admin is slowed down by fetching related objects one at a time. This includes fields that are not being edited.
I believe the standard way to alleviate this problem is to use select_related. When you need select_related for the admin, you override ModelAdmin.queryset. So I have mimicked the pattern used for massadmin_exclude and added the capability to override the default queryset by defining a massadmin_queryset method on a ModelAdmin.
Perhaps the code is even simpler than my explanation...
I have run into a situation where the mass admin is slowed down by fetching related objects one at a time. This includes fields that are not being edited.
I believe the standard way to alleviate this problem is to use
select_related
. When you needselect_related
for the admin, you overrideModelAdmin.queryset
. So I have mimicked the pattern used formassadmin_exclude
and added the capability to override the default queryset by defining amassadmin_queryset
method on aModelAdmin
.Perhaps the code is even simpler than my explanation...