django xadmin自定义菜单

1. 自定义菜单

adminx.py

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

# -*- coding:utf-8 -*-
from xadmin import Settings
class Base(Settings):
    enable_themes = True
    #use_bootswatch = True

class Comm(Settings):
    menu_style = 'accordion'

 

settings.py

XADMIN_CONF = 'web.xsite'

 

转载请注明来源:http://www.cnblogs.com/Tommy-Yu/p/5403315.html

posted @ 2016-04-18 09:53  tommy.yu  阅读(4284)  评论(0编辑  收藏  举报