1.安装xadmin
使用pip install xadmin安装
2.在settings.py中注册xadmin
INSTALLED_APPS = [
....
...
'xadmin',
'crispy_forms',
]
3.配置urls.py中管理员的网址
import xadmin
from django.conf.urls import url
urlpatterns = [
url(r'^xadmin/', xadmin.site.urls),
]
4.数据表注册
from .models import *
import xadmin
class UserAdmin(object):
list_display = ['name', 'desc', 'add_time']
search_fields = ['name', 'desc']
list_filter = ['name', 'desc', 'add_time']
xadmin.site.register(User, UserAdmin)
5.网页配置
from xadmin import views
import xadmin
class GlobalSettings(object):
site_title = '东哥后台管理系统' # 修改页眉
site_footer = '东哥学习网' # 修改页脚
menu_style = 'accordion' #修改菜单栏 改成收缩样式
语言时间配置
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True