diff --git a/db.sqlite3 b/db.sqlite3 index bd9bf79da7627c5265de8dfbbc31d77ad927821b..11c2216cacb18ac25b12aaea6d01d0ccbe383d74 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/demo/admin.py b/demo/admin.py index 6f449f193f9655447129932edd4eb208bfcbe9b4..aab50cc9603c288f3fc2fb343b9ed1627fe3dfef 100644 --- a/demo/admin.py +++ b/demo/admin.py @@ -70,20 +70,34 @@ class AgeListFilter(admin.SimpleListFilter): @admin.register(Employe) class EmployeAdmin(admin.ModelAdmin): - list_display = ('id', 'name', 'gender', 'idCard', 'phone', 'birthday', 'department', 'enable', 'create_time') - search_fields = ('name', 'enable') + list_display = ('id', 'name', 'gender', 'phone', 'birthday', 'department', 'enable', 'create_time') + search_fields = ('name', 'enable', 'idCard', 'department') list_per_page = 10 raw_id_fields = ('department', 'title') list_filter = ('department', AgeListFilter) # list_filter = (AgeListFilter, 'department', 'create_time', 'birthday', 'time', 'enable', 'gender') - list_display_links = ('name', 'idCard') + list_display_links = ('name',) list_editable = ('department', 'phone', 'birthday', 'enable', 'gender') date_hierarchy = 'create_time' # 增加自定义按钮 - actions = ['make_copy'] + actions = ['make_copy', 'custom_button'] + + def custom_button(self, request, queryset): + pass + + # 显示的文本,与django admin一致 + custom_button.short_description = '测试按钮' + # icon,参考element-ui icon与https://fontawesome.com + custom_button.icon = 'fas fa-audio-description' + + # 指定element-ui的按钮类型,参考https://element.eleme.cn/#/zh-CN/component/button + custom_button.type = 'danger' + + # 给按钮追加自定义的颜色 + custom_button.style = 'color:black;' def make_copy(self, request, queryset): ids = request.POST.getlist('_selected_action')