我用的是Django1.11.6版本
下载地址:https://github.com/sshwsfc/xadmin
下载下来有一个requirements.txt 文件 这里面是所依赖的库
一 一安装
1、在相应的app当中创建adminx.py文件
2、在adminx.py文件当中注册我们的每一个model
import xadmin
from users.models import EmailVerify
class EmailVerifyXadmin(object):
list_display = ['email', 'code', 'send_type', 'add_time']
search_fields = ['email', 'code', 'send_type']
list_filter = ['email', 'code', 'send_type', 'add_time']
#注册
xadmin.site.register(EmailVerify, EmailVerifyXadmin)
from django.apps import AppConfig
class UsersConfig(AppConfig):
name = 'users'
verbose_name = '用户模块'
2.在app当中的__init__文件中添加配置
default_app_config = 'users.apps.UsersConfig'
或者直接在settings中INSTALL_APPS中设置 写成 orgs.apps.OrgsConfig
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'users.apps.UsersConfig',
'orgs.apps.OrgsConfig',
'operations.apps.OperationsConfig',
'courses.apps.CoursesConfig',
'xadmin',
'crispy_forms',
'captcha'
]
设置主题
from xadmin import views
class BaseXadminSettings(object):
enable_themes = True
use_bootswatch = True
class GlobaSiteSettings(object):
site_title = 'xxx后台管理系统'
site_footer = 'xxx'
menu_style = 'accordion'
xadmin.site.register(views.BaseAdminView, BaseXadminSettings)
xadmin.site.register(views.CommAdminView, GlobaSiteSettings)
注册后台
在app中创建python文件 adminx.py
class EmailVerifyXadmin(object):
list_display = ['email', 'code', 'send_type', 'add_time']
search_fields = ['email', 'code', 'send_type']
list_filter = ['email', 'code', 'send_type', 'add_time']
xadmin.site.register(EmailVerify, EmailVerifyXadmin)