1,配置中文
我们来到settings 中下位置可以看到这样几个参数:
LANGUAGE_CODE = 'en-us'TIME_ZONE = 'UTC'USE_I18N = TrueUSE_L10N = TrueUSE_TZ = True
改为:
LANGUAGE_CODE = 'zh-hans'TIME_ZONE = 'Asia/Shanghai'USE_I18N = TrueUSE_L10N = TrueUSE_TZ = False
2,添加一个adminx.py
(1)引入头文件和Model类的函数
import xadminfrom .models import UserInfor
(2)显示配置
class UserInforAdmin(object):
list_display = ("Date","id", "Openid","Gold","Gem","Cup","Level")# 设置显示的字段
list_editable = ["Gold","Gem","Cup","Level"]# 设置默认可编辑字段
search_fields = ("Openid","Gold","Gem","Cup","Level") # 搜索字段
# 字段分类
# fieldsets=[
# ['Base',{'fields':["Openid",]}],
# ['Other', {'fields': ["Gold","Gem"]}]
# ]
# ordering设置默认排序字段,负号表示降序排序
ordering = ('-Date',)
list_per_page = 10
date_hierarchy = 'Date' # 详细时间分层筛选
# Action for mutiple selected items delete
def DeleteSelected(self, request, queryset):
queryset.delete()
self.message_user(request, '删除成功!!')
DeleteSelected.short_description = '删除所选'
(3)添加关联
xadmin.site.register(UserInforClass,UserInforAdmin)
3,全局配置
在adminx.py里面添加头文件
from xadmin import views
然后配置:
class GlobalSettings(object):
site_title = 'xx后台管理系统' # 修改页眉
site_footer = 'xx' # 修改页脚
menu_style = 'xx菜单' #修改菜单栏 改成收缩样式
下一篇:没废话保证绝对可行教程(3.2)Django+RestFramework+Xadmin开发之:主题配置:https://www.jianshu.com/p/861230a1eeab