美文网首页
django配置xadmin

django配置xadmin

作者: ljwheyxy | 来源:发表于2019-10-30 14:34 被阅读0次

    1、安装xadmin

    参见我的另一篇文章

    2、 在installed_app中注册

        'xadmin',
        'crispy_forms',
        'reversion',
    

    3、配置urls(创建项目时的总的urls)

    from django.contrib import admin
    from django.urls import path, re_path, include
    import xadmin
    xadmin.autodiscover()
    
    from xadmin.plugins import xversion
    xversion.register_models()
    
    
    path('xadmin/', xadmin.site.urls),
    

    4、在子应用中配置“adminx.py”文件

    from xadmin import views
    from .models import Banner, Nav
    import xadmin
    
    
    class BaseSetting(object):
        enable_themes = True  # 开启主题切换
        use_bootswatch = True
    
    
    xadmin.site.register(views.BaseAdminView, BaseSetting)
    
    
    class GlobalSettings(object):
        """xadmin的全局配置"""
        site_title = "sitename"
        site_footer = "x科技有限责任公司技术支持"
        menu_style = "accordion"  # 设置菜单折叠
    
    
    xadmin.site.register(views.CommAdminView, GlobalSettings)
    
    
    class BannerModelAdmin(object):
        list_display = ['name', 'orders', 'is_show']
    
    
    xadmin.site.register(Banner, BannerModelAdmin)  # 注册模型
    

    相关文章

      网友评论

          本文标题:django配置xadmin

          本文链接:https://www.haomeiwen.com/subject/bfvovctx.html