提交 7060b109 编写于 作者: N newpanjing

功能增加

上级 5fd2310a
无法预览此类型文件
from django.contrib import admin
from django.urls import reverse
from .models import *
......@@ -17,6 +19,19 @@ class DepartmentAdmin(admin.ModelAdmin):
actions_on_top = True
@admin.register(Title)
class TitleAdmin(admin.ModelAdmin):
# 要显示的字段
list_display = ('id', 'name')
# 需要搜索的字段
search_fields = ('name',)
# 分页显示,一页的数量
list_per_page = 10
@admin.register(Employe)
class EmployeAdmin(admin.ModelAdmin):
list_display = ('id', 'name', 'gender', 'idCard', 'phone', 'birthday', 'department', 'enable', 'create_time')
......
from django.db import models
# Create your models here.
from django.urls import reverse
class Department(models.Model):
name = models.CharField(max_length=128, verbose_name='部门名', help_text='一个部门的名字应该唯一', unique=True, db_index=True)
......@@ -15,6 +16,20 @@ class Department(models.Model):
return self.name
class Title(models.Model):
name = models.CharField(max_length=128, verbose_name='职务', null=True, blank=True)
class Meta:
verbose_name = '职务'
verbose_name_plural = '职务管理'
def get_absolute_url(self):
return reverse('title-detail-view', args=(self.name,))
def __str__(self):
return self.name
class Employe(models.Model):
name = models.CharField(max_length=128, verbose_name='名称', help_text='员工的名字', null=False, blank=False,
db_index=True)
......@@ -36,6 +51,9 @@ class Employe(models.Model):
department = models.ForeignKey(Department, on_delete=models.SET_NULL, blank=False, null=True, verbose_name='部门',
db_index=True)
title = models.ForeignKey(Title, on_delete=models.SET_NULL, blank=False, null=True, verbose_name='职务',
db_index=True)
enable = models.BooleanField(verbose_name='状态', default=True)
create_time = models.DateTimeField(verbose_name='创建时间', auto_now=True)
......
......@@ -29,8 +29,8 @@ ALLOWED_HOSTS = ['*', ]
# Application definition
INSTALLED_APPS = [
'import_export',
'simpleui',
'import_export',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
......@@ -153,36 +153,36 @@ STATIC_ROOT = os.path.join(BASE_DIR, "static")
SIMPLEUI_ANALYSIS = True
# 自定义simpleui 菜单
# SIMPLEUI_CONFIG = {
# # 在自定义菜单的基础上保留系统模块
# 'system_keep': False,
# 'menus': [{
# 'name': 'Simpleui',
# 'icon': 'fas fa-code',
# 'url': 'https://gitee.com/tompeppa/simpleui'
# }, {
# 'app': 'auth',
# 'name': '权限认证',
# 'icon': 'fas fa-user-shield',
# 'models': [{
# 'name': '用户',
# 'icon': 'fa fa-user',
# 'url': 'auth/user/'
# }]
# }, {
# 'name': '测试',
# 'icon': 'fa fa-file',
# 'models': [{
# 'name': 'Baidu',
# 'url': 'http://baidu.com',
# 'icon': 'far fa-surprise'
# }, {
# 'name': '内网穿透',
# 'url': 'https://www.wezoz.com',
# 'icon': 'fab fa-github'
# }]
# }]
# }
SIMPLEUI_CONFIG = {
# 在自定义菜单的基础上保留系统模块
'system_keep': True,
'menus': [{
'name': 'Simpleui',
'icon': 'fas fa-code',
'url': 'https://gitee.com/tompeppa/simpleui'
}, {
'app': 'auth',
'name': '权限认证',
'icon': 'fas fa-user-shield',
'models': [{
'name': '用户',
'icon': 'fa fa-user',
'url': 'auth/user/'
}]
}, {
'name': '测试',
'icon': 'fa fa-file',
'models': [{
'name': 'Baidu',
'url': 'http://baidu.com',
'icon': 'far fa-surprise'
}, {
'name': '内网穿透',
'url': 'https://www.wezoz.com',
'icon': 'fab fa-github'
}]
}]
}
# 是否显示默认图标,默认=True
# SIMPLEUI_DEFAULT_ICON = False
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册