原生Django
-
list_display (tuple) table 显示的字段
-
search_fields (tuple) 搜索框搜索的字段
-
list_per_page (int) 每页显示的数量
-
list_filter (array) 筛选字段
-
list_display_links 显示连接进入编辑页的字段
-
fields_options (dict) 表格的表头字段设置
-
actions_show (boolean) 显示隐藏 action,默认为 True,只有显式指定为 False 的时候才隐藏
-
actions (array) 自定义按钮
-
readonly_fields 设置model中的指定字段只读
Simpleui Pro
- native_render (boolean) 使用原生ModelAdmin页面渲染,默认为Flase
- list_filter_multiples (array) 自3.1版本起可用,搜索下拉框多选字段,比如要在list_filter中包含才生效
- top_html (str) 列表顶部显示的 html,支持 vue 组件和 element 组件
- bottom_html (str) 列表底部显示的 html,支持 vue 组件和 element 组件
# 去除 添加按钮
def has_add_permission(self, request):
return False
# 去除更改按钮
def has_change_permission(self, request, obj=None):
return False
# 去除 删除按钮
def has_delete_permission(self, request, obj=None):
return False
# 自定义按钮
def custom_button(self, request, queryset):
return http.JsonResponse(data={
'status': 'success',
'msg': '更新成功!'
})
# 默认可点击
custom_button.enable = True
# 显示的文本
custom_button.short_description = '更新视频列表'
# icon,参考element-ui icon与https://fontawesome.com
custom_button.icon = 'el-icon-s-help'
custom_button.type = 'success'
# 提示框
del_button.confirm = '你是否执意要点击该按钮,数据不可找回!!!'
# 设置成链接按钮
# action_type 0=当前页内打开,1=新tab打开,2=浏览器tab打开
# 设置了action_type,不设置url,页面内将报错
# 设置成链接类型的按钮后,custom_button方法将不会执行。
# custom_button.action_type = 1
# custom_button.action_url = "http://www.baidu.com"
转自:查看详情