我有这个模型管理员 -
class NewsAdmin(ImageWidgetAdmin):
image_fields = ['featured_image']
list_per_page = 20
list_display = ('heading', 'category', 'status', 'is_active', 'created_at', 'published_at',
'created_by', 'published_by')
list_editable = ('category', 'status', 'is_active')
list_filter = ('published_at', 'created_at', 'status', 'is_active', 'created_by',
'published_by',)
search_fields = ('heading', 'category', 'tags', 'source')
actions = [enable_object, disable_object, status_draft, status_private, status_public]
actions_on_bottom = True
加载最多只需要 400 毫秒。这是 django-debug-toolbar 图像 -
但是当我覆盖语言过滤对象的 get_queryset 方法时 -
def get_queryset(self, request):
queryset = super(NewsAdmin, self).get_queryset(request)
return queryset.filter(language=request.LANGUAGE_CODE)
大约需要 17-18 秒,这太疯狂了!!这是 django-debug-toolbar 图像 -
甚至前端查询也会发生这种情况!有关详细信息 - 我有大约 40 万条记录的数据库表,这是模型 -
MMMHUHU
湖上湖
随时随地看视频慕课网APP
相关分类