Answers for "django admin prefetch_related"

3

django admin prefetch_related

from django.contrib import admin

class MyModelAdmin(admin.ModelAdmin):
    def get_queryset(self, request):
        queryset = super(MyModelAdmin, self).get_queryset(request)
        queryset = queryset.prefetch_related('user')
        return queryset
Posted by: Guest on August-04-2021

Python Answers by Framework

Browse Popular Code Answers by Language