Install the xadmin background management plugin

Django's own admin background management functions are too few. Using the xadmin background developed by the Chinese, when using pip install xadmin to install the online package, there will be an error, the README.rst is in utf8 format, and our win7 system defaults to gbk format, which causes the installation to fail. At this time, you need to download the xadmin installation package file suitable for django2. The download address is not the default master branch of xadmin, but the django2 branch:

 

https://github.com/sshwsfc/xadmin/tree/django2

I have downloaded and replaced the README.rst file in it at:

 

Link: https://pan.baidu.com/s/1rux8sDK9thhbZ1qjwQg6kA Password: iq4c

 

After downloading, use cmd to enter the folder and use pip to install:

pip install xadmin-django2.zip

 

Then the relevant dependencies will be installed,

 

Register the xadmin module in settings

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'users',
    'courses',
    'organizations',
    'operations',
    xadmin'',
    'crispy_forms',
]

 

Modify urls.py

 

from django.contrib import admin
from django.urls import path
import xadmin

urlpatterns = [
    path('xadmin/', xadmin.site.urls),
]

 

Comment out all the code in admin.py in the users module, then migrate the data

makemigrations

migrate

Open the browser to view the background xadmin

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325216260&siteId=291194637