栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

今天的Django教训汇总:admin后台设定-20211108

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

今天的Django教训汇总:admin后台设定-20211108

admin.py

链接

from django.contrib import admin
from PPDASH.models import *
from django.db import models


### 定义EmployeeAdmin的属性
class EmployeeAdmin(admin.ModelAdmin):
    #list_display = ('dept_code','level','function','eid', 'name')
    list_display = ('dept_code','level','function','eid', 'name','score_jieshoufankui','score_xueximinruidu',
                'score_jieguodaoxiang','score_quanjusiwei','score_shiyingli','score_chengjiutaren','score_lingdaoyiyuan',
                'score_pinghengrenjiyurenwu','score_fudao','score_shouquanweize','score_jianlichenggongtuandui',
                'score_guanlirenjiguanxi','score_yingxiangli','score_jianlihuobanguanxi','score_jihuayuzuzhi',
                )
    ordering = ['dept_code']
    search_fields = ('dept_code','eid','name',)
    list_display_links = ('dept_code','eid','name',)
    #list_filter = ('batch', )
    list_per_page = 10
    # list_editable = ['dept_code','score_jieshoufankui','score_xueximinruidu',
    #             'score_jieguodaoxiang','score_quanjusiwei','score_shiyingli','score_chengjiutaren','score_lingdaoyiyuan',
    #             'score_pinghengrenjiyurenwu','score_fudao','score_shouquanweize','score_jianlichenggongtuandui',
    #             'score_guanlirenjiguanxi','score_yingxiangli','score_jianlihuobanguanxi','score_jihuayuzuzhi',] #list_editable 设置默认可编辑字段
    site_header = "PP结果管理系统"     # 添加页面显示标题




### 上传Employee的数据所需
# 因为我们要在后台保存,所以我们需要重写ModelAdmin的save_mode
from .utils import import_employee
class importEmployeeFileAdmin(admin.ModelAdmin):

    list_display = ('file','name',)
    list_filter = ['name',]

    def save_model(self, request, obj, form, change):

        re = super(importEmployeeFileAdmin,self).save_model(request, obj, form, change)
        import_employee(self, request, obj, change)
        return re





# Register your models here.
admin.site.register(Employee,EmployeeAdmin)
admin.site.register(import_Employee,importEmployeeFileAdmin)
admin.site.site_header = "PP结果管理系统"

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/444690.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号