burke-software / django-mass-edit

Make bulk changes in the Django admin interface
152 stars 67 forks source link

Add for massadmin_queryset on the ModelAdmin being edited #22

Closed kennknowles closed 10 years ago

kennknowles commented 10 years ago

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...

kennknowles commented 10 years ago

It might even make sense to default to self.admin_obj.queryset.

bufke commented 10 years ago

Thanks. Seems fine. Could you document a use case example for it too? Ideally we should write some unit tests too...