如何从“全部”更改默认过滤器选择?我有一个名为领域status它有三个值:activate,pending和rejected。当我list_filter在Django admin中使用时,过滤器默认情况下设置为“全部”,但我想默认将其设置为待处理。
status
activate
pending
rejected
list_filter
class MyModelAdmin(admin.ModelAdmin): def changelist_view(self, request, extra_context=None): if not request.GET.has_key('decommissioned__exact'): q = request.GET.copy() q['decommissioned__exact'] = 'N' request.GET = q request.META['QUERY_STRING'] = request.GET.urlencode() return super(MyModelAdmin,self).changelist_view(request, extra_context=extra_context)