Using xadmin to override Django's admin

Install xadmin

pip install xadmin may report an error

pip install git+git://github.com/sshwsfc/xadmin.git

 

To use after installation, you need to register three app s in setting

INSTALLED_APPS = [
    ....
    #xadmin
    'xadmin',
    'crispy_forms',
    'reversion',


]

Modify the urls.py file in the root directory

import xadmin
xadmin.autodiscover()
from xadmin.plugins import xversion
xversion.register_models()


urlpatterns = [
    url(r'^xadmin/', include(xadmin.site.urls)),

Then you need to create a new adminx.py file to register your model

# -*- coding: utf-8 -*-
# from django.contrib import admin
import xadmin
from .models import *
from xadmin import views
# Register your models here.
#
class GlobalSettings(object):
    site_title = "Wellhotel Background management system"
    site_footer = "Wellhotel Background management system"
   menu_style = 'accordion'
class basesetting(object): 
  enable_themes
= True
  use_bootswatch
= True

xadmin.site.register(views.CommAdminView,GlobalSettings)
xadmin.site.register(views.BaseAdminView,basesetting)
xadmin.site.register(subclass_details)
xadmin.site.register(Organization)
xadmin.site.register(DeviceInfo)
# xadmin.site.register(NormalUser)
xadmin.site.register(Price)
The site "title in the global settings is the log in the upper left corner of xadmin, and the site" footer "is the log under xadmin. Menu? Style to set the left navigation bar to the type of click-down
basesetting is to open the theme system in the background. xadmin is off by default. After opening, you can select different themes.

Set the name of the app to Chinese. It's the app you created. Modify apps.py
# -*- coding: utf-8 -*-
from django.apps import AppConfig


class XprojectConfig(AppConfig):
    name = 'xproject'
    verbose_name = 'project'

Then modify it in init.py

default_app_config = "xproject.apps.XprojectConfig"

Official document https://xadmin.readthedocs.io/en/docs-chinese/quickstart.html#

Tags: Python git pip Django github

Posted on Tue, 03 Dec 2019 00:43:01 -0800 by buildernaut1