zoukankan      html  css  js  c++  java
  • django Xadmin替换admin

    django-Xadmin替换admin

    1、下载:

    下载地址:https://github.com/sshwsfc/xadmin/tree/django2

    2、安装

    用pip 安装下载的包

    sudo pip3 install xadmin~=2.0

    或打开项目路径(如图:forum项目路径):

    3.配置setting.py

    INSTALLED_APPS = [
    ...
    'xadmin',
    ...
    ]

    4.更改app下的admin.py

    import xadmin
    
    #用户表
    class UserAdmin:
        list_display =['username','password','nickname','phone','birthday','mail','head_img']
        fields = ('username','password','nickname','phone','birthday','mail','head_img')
        search_fields = ['username']
        save_on_top = True
    
    
    
    xadmin.site.register(User, UserAdmin)
    
    #地址表
    class AddressAdmin:
        list_display =['address']
        fields =('address',)
        save_on_top = True
    
    
    xadmin.site.register(Address,AddressAdmin)

    配置url(将原本指向admin的url改为xadmin):

    import xadmin
    from .custom_site import custom_site
    
    
    urlpatterns = [
    
        path(r'xadmin/', xadmin.site.urls),
        # path('admin/', custom_site.urls),
    
        path('index/',include('blog.urls')),
    
    
    ]

    5.配置数据迁移和超级用户,启动服务:

    pyhton3 manage.py createsuperuser
    python3 manage.py makemigrations
        ...... migrate
        ...... runserver

    127.0.0.1:8000/xadmin

  • 相关阅读:
    说说移动端web开发中的点击穿透问题
    将博客搬至CSDN
    IIS(4)
    IIS(2)
    IIS(3)
    IIS(1)
    链表
    常用到的关键字
    进程与线程
    文件系统的原理
  • 原文地址:https://www.cnblogs.com/yongqi-wang/p/13691273.html
Copyright © 2011-2022 走看看