Django admin performance issue

后端 未结 2 1736
孤独总比滥情好
孤独总比滥情好 2021-01-21 21:51

I\'m getting thousands of these queries when I try to open up a model in the Django admin interface and it\'s leading to a serious performance issue.

[sql] SELEC         


        
2条回答
  •  被撕碎了的回忆
    2021-01-21 22:12

    You could make Django use select_related by defining your own ModelAdmin like this

    class MyModelAdmin(admin.ModelAdmin):
        def queryset(self, request):
            qs = super(MyModelAdmin, self).queryset(request)
            return qs.select_related()
    

提交回复
热议问题