def btn_test(self, request, queryset):
post = request.POST
print(post['domain_id'])
return JsonResponse(data={
'status': 'success',
'msg': '选中:'+post['domain_id']
})
btn_test.short_description = '切换'
btn_test.icon = "el-icon-sort"
btn_test.type = 'success'
btn_test.enable = True
btn_test.layer ={
'title': '切换域名',
# 提示信息
'tips': '请选择域名',
# 确认按钮显示文本
'confirm_button': '确认',
# 取消按钮显示文本
'cancel_button': '取消',
'width': '30%',
'labelWidth': "60px",
'params': [{
'type': 'select',
'key': 'domain_id',
'label': '域名',
'width': '400px',
'size': 'medium',
'options': list_some,
}]
}
project_list = API.objects.filter(api_id=api_id)
list_some= [{'key':str(i.api_domain_id),'label':i.api_domain_name} for i in project_list ]
以上代码应该写在admin.py 的哪里才能让下拉列表有数据???