def pass_audit_str(self):
parameter_str = 'id={}&status={}'.format(str(self.id), str(self.audit))
color_code = ''
btn_str = '<a class="btn btn-xs btn-danger" href="{}">' \
'<input name="通过审核"' \
'type="button" id="passButton" ' \
'title="passButton" value="通过审核">' \
'</a>'
return format_html(btn_str, '/pass_audit/?{}'.format(parameter_str))
pass_audit_str.short_description = '通过审核'
在model类添加上面的方法和语句。
在admin类中的把 pass_audit_str 加入到list_display元组中
list_display = ('id', 'create_time', 'pass_audit_str',)
刷新页面即可;