1、 stay setting I quote import_export
INSTALLED_APPS = [
‘simpleui’,
‘import_export’,
‘django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘middlewares’,
‘Baseinfo’,
‘Siteloginfo’
]
2、 structure models
class personinfo(models.Model):
## Define enum value status
Employee number = models.CharField(‘ Employee number ’, max_length=128, primary_key=True)
full name = models.CharField(‘ full name ’, max_length=128)
Local market = models.CharField(‘ Local market ’, max_length=128)
department = models.CharField(‘ department ’, max_length=128)
Talent level = models.CharField(‘ Talent level ’, max_length=128)
Talent major = models.CharField(‘ Talent major ’, max_length=128)
class Meta:
verbose_name = " Employee information "
verbose_name_plural = " Employee information "
3、 stay admin.py Construct the display module in
from django.contrib import admin
from django.db import models
from django.forms import Textarea, TextInput
from Baseinfo.models import personinfo
from import_export.admin import ExportMixin
admin.site.site_header = ‘ project management ’
admin.site.site_title = ‘ Management system ’
admin.site.index_title = ‘ Management system ’
class personadmin(ExportMixin,admin.ModelAdmin):
resource_class = personinfo
# Set the fields that the page can display
list_display = (‘ full name ’,‘ Local market ’,‘ department ’,‘ Talent level ’,‘ Talent major ’)
# If it is not configured by default , The first field will have a link to the record editing page
# list_display_links = None
# list_display_links = (‘ Station name ’,)
# Set filtering options
list_filter = (‘ Local market ’,‘ Talent level ’)
# Number of entries per page The default value 100
list_per_page = 10
# show all On the page model number , default 200
# list_max_show_all = 200
# Set editable fields If the editable field is set , The page will automatically add a save button
list_editable = (‘ Local market ’,‘ department ’,‘ Talent level ’,‘ Talent major ’)
# Filter by date month This attribute is generally not used
# date_hierarchy = [‘BBU Completion time of centralized transformation ’,‘ Time when power supply transformation conditions are met ’,‘ Completion time of survey ’,‘ Design completion time ’,‘ Arrival time ’,‘ Completion time of transformation ’]
# Sort by release date in descending order
ordering = (‘ Local market ’,‘ Talent level ’)
# Search criteria settings
search_fields = (‘ full name ’,‘ Local market ’,‘ department ’,‘ Talent level ’)
# Add custom button
# fieldsets = (
# (' essential information ', {
# 'fields': (' Local market ',' Station name ',' Main equipment manufacturer ',' The station is equipped with battery capacity ',)
# }),
# (' Time schedule ', {
# 'fields': ('BBU Completion time of centralized transformation ',' Time when power supply transformation conditions are met ',' Completion time of survey ',' Design completion time ',' Arrival time ',' Completion time of transformation ')
# }),
# )
# def has_delete_permission(self, request, obj=None):
# # Disable delete button
# return Fals
# Read-only fields
# readonly_fields = (' Local market ',' Station name ',' Main equipment manufacturer ',' The station is equipped with battery capacity ',)
formfield_overrides = {
models.CharField: {'widget': TextInput(attrs={'size':'20'})},
}
admin.site.register(personinfo,personadmin)
among formfield_overrides = {
models.CharField: {‘widget’: TextInput(attrs={‘size’:‘20’})},
} Define the displayed field width
Used for registration models :admin.site.register(personinfo,personadmin)
4、 stay setting in Definition url
SIMPLEUI_CONFIG = {
‘system_keep’: False, # Close the system menu
‘menu_display’: [‘ project management ’,‘ Login Statistics ’,‘ task management ’, ‘ information management ’,‘ Website management ’, ‘ Certification and authorization ’],
‘dynamic’: True, # Set whether to open dynamic menu , The default is False. If open , The menu content will be displayed dynamically every time the user logs in
‘menus’: [{
‘app’: ‘Projectmanage’,
‘name’: ‘ project management ’,
‘icon’: ‘fab fa-app-store-ios’,
‘models’: [{
‘name’: ‘ Fill in the project schedule ’,
‘icon’: ‘fa fa-user’,
‘url’: ‘Baseinfo/personinfo/’
},