zoukankan      html  css  js  c++  java
  • Django-Xadmin记录

    1 下载源码:https://github.com/sshwsfc/xadmin

    2 加入工程文件

    3 pip install -r > requestments.txt

    django>=2
    django-crispy-forms>=1.6.0
    django-import-export>=0.5.1
    django-reversion>=2.0.0
    django-formtools==2.1
    future==0.15.2
    httplib2==0.9.2
    six==1.10.0
    

    4 Setting文件安装

    INSTALLED_APPS = [
        'xadmin',
        'crispy_forms',
    ]
    

     5 ModuleNotFoundError: No module named 'xadmin' setting加入路径

    BASE_DIR=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    sys.path.insert(0,os.path.join(BASE_DIR,'extra_apps'))
    sys.path.insert(1,os.path.join(BASE_DIR,'apps'))
    

     6 ModuleNotFoundError: No module named 'django.contrib.formtools':将版本改成django-formtools==2.1

     7 创建数据模型后新建adminx.py注册:分别为显示、搜索、过滤、图标

      

    from message.models import Msg
    from xadmin.sites import site
    
    class MsgAdmin(object):
        list_display = ['name','msg_content','msg_email','msg_time']
        search_fileds = ['name','msg_content','msg_email','msg_time']
        list_filter = ['name','msg_content','msg_email','msg_time','msg_sex']
        model_icon = 'fa fa-book fa-fw'
    
    site.register(Msg,MsgAdmin)
    

     8 创建adminx.py

    from xadmin import views
    from job.models import job51
    from xadmin.sites import site
    # Register your models here.
    
    class Job51Admin(object):
        refresh_times = [10,20,50]
        search_fields =('date','jobaddress')
        list_display = ('job','company','jobaddress','date','wages','joburl')
        model_icon = 'fa fa-home fa-fw'
        ordering = ['-date']
    site.register(job51,Job51Admin)
    
    
    #添加主题功能
    class BaseSetting(object):
        enable_themes = True
        use_bootswatch = True
    site.register(views.BaseAdminView, BaseSetting)
    
    
    #修改头文件及脚本显示
    class GlobalSetting(object):
        site_title = "喻晓生后台管理系统"
        site_footer = "http://daydayup11.cn"
        menu_style = "accordion"
    site.register(views.CommAdminView, GlobalSetting)
    

     9 django.urls.exceptions.NoReverseMatch: Reverse for 'xadmin_userwidget_add' with no argumen:报错原因adminx/后面不能加$

    10 python manage.py createsuperuser创建用户、migrations、migrate

    11   http://192.168.2.246:8000/xadmin/访问

  • 相关阅读:
    约瑟夫问题
    LCIS(最长公共上升子序列)
    Spfa求负环
    裴蜀(贝祖)定理
    Tarjan算法之简单缩点
    树形dp-二次扫描+换根
    sys.path.insert
    python学习之路(十二)
    python学习之路(十一)
    python学习之路(十)
  • 原文地址:https://www.cnblogs.com/acer-haitao/p/9039739.html
Copyright © 2011-2022 走看看