# 自定义按钮不勾选也可以执行 def changelist_view(self, request, extra_context=None): if 'action' in request.POST and request.POST['action'] == 'request_data': # 自定义按钮名称 if not request.POST.getlist(ACTION_CHECKBOX_NAME): post = request.POST.copy() for u in models.PieData.objects.all(): post.update({ACTION_CHECKBOX_NAME: str(u.id)}) request._set_post(post) return super(PieData, self).changelist_view(request, extra_context) # 爬取数据 def request_data(self,request,queryset): print("执行了") return True request_data.short_description = '爬取数据'
标签:不勾选,自定义,Admin,request,按钮,post,POST From: https://www.cnblogs.com/wanghong1994/p/16825860.html