点击自定义按钮后希望在get_queryset()里获取所点击按钮的名称。
底层群员-吴彦祖Pro回答: def get_queryset(self, request): if request.POST.get("action") = "自定义按钮": return Model.object.filter(审核状态="待审核") else: return super(Model, self).get_queryset(request)
但还是有问题(request.POST.get(“action”)),我增加一个打印观察获得的值:
print(request.POST.get("action"))
if request.POST.get("action") == 'fc_action_audit':
return UsersUnit.objects.filter(audit_status=1)
else:
return super(UsersUnitAdmin, self).get_queryset(request)
没有点按纽时值为:None, 点击按钮后值为:custom_action.
究竟如何获取自定义按钮名称'fc_action_audit'