1、 自定义菜单
adminx.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
class GlobalSetting( object ): site_title = u 'xxx后台' def kuF_site_menu( self ): return [{ 'title' : u '用户&账户' , 'perm' : self .get_model_perm(User, 'view' ), 'icon' : 'fa fa-users' , 'menus' :( { 'title' : u '用户' , 'url' : self .get_model_url(User, 'changelist' )}, { 'title' : u '账户' , 'url' : self .get_model_url(Account, 'changelist' ), 'perm' : self .get_model_perm(Account, 'view' ), }, { 'title' : u '用户套餐' , 'url' : self .get_model_url(AccountLogs, 'changelist' ), 'perm' : self .get_model_perm(AccountLogs, 'view' ), }, ) }, ] def get_site_menu( self ): menus = [] from xxx_app.adminx import card_pool_site_menu menus.extend(card_pool_site_menu( self )) menus.extend( self .kuF_site_menu()) return menus xadmin.site.register(CommAdminView, GlobalSetting) |
2、 折叠
增加xsite文件及配置
xsite.py
1
2
3
4
5
6
7
8
|
# -*- coding:utf-8 -*- from xadmin import Settings class Base(Settings): enable_themes = True #use_bootswatch = True class Comm(Settings): menu_style = 'accordion' |
settings.py
1
|
XADMIN_CONF = 'web.xsite' |
以上这篇对django xadmin自定义菜单的实例详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://www.cnblogs.com/Tommy-Yu/p/5403315.html