This article is for study only, if there are mistakes, welcome to point out

During the project configuration process, if there are any errors, please slide to the bottom of the article there are partial error solutions. You can also leave a comment below

Djangos Admin system was mentioned in the previous section

There’s an app mentioned here called Xadmin

So I wanted to give it a try

Don’t talk too much

Download Xadmin

Bootstrap3 is a powerful django plug-in system.

Unfortunately, the Django website seems to have stopped maintenance

But still have a lot of his projects, the address https://github.com/sshwsfc/xadmin

Clone to your desktop

.

So we have an xadmin-master package

Remaining dependencies

django>=2
django-crispy-forms>=1.6. 0
django-import-export>=0.51.
django-reversion>=2.0. 0
django-formtools==2.0
future==0.152.
httplib2==0.92.
six==1.10. 0
Copy the code

Direct PIP installation is easy and hassle-free

Where is the document?

https://xadmin.readthedocs.io/en/latest/quickstart.html

application

Create a Django project

Myxadmin is my project package

Apps is the folder where I store the apps I create

The folder extra_apps uses to hold third-party apps, and we put the xadmin folder under that folder

One issue we need to be aware of here is django’s flow

When we visit http://127.0.0.1:8000/admin, django will enter our configuration

Enter when you find our admin

But here we need to replace admin with xadmin

So we’re going to do it here

1. Comment out admin.py for all apps you create && you can create a adminx.py file for your project

The model class you want to register is no longer written under the molde class, but under adminx.py

2. Under setting.py, insert the following contents to beautify our interface

3. Add project environment to system environment

4. Change admin to xadmin

5.python manage.py runserver

Indeed, the background is much more aesthetically pleasing than the previous Admin screen

Register our model class

from .models import Student
import xadmin


class StudnetAdmin(object):
    list_display = ['title'.'num']  Set the field of the table to display in the background
    list_filter = ('country'.)# filterable field
    search_fields = ('name'.'city'.)# searchable field
    list_editable= ['is_hot'].# editable
    style_fields = {"goods_desc": "ueditor"} # inheritance ueditor
xadmin.site.register(Student,StudnetAdmin)
Copy the code

StudentAdmin; admin.adminModel; object

Just because there are no smart hints, don’t assume that you don’t have these attributes and can still apply them

A: wow! The subject is ugly

If you’re not single-minted at all and want to look at different themes under Xadmin, make basic Settings changes under your xadmin.py

class BaseSetting(object):
    enable_themes = True  Is it possible to switch themes
    use_bootswatch = True # More theme features
xadmin.site.register(xadmin.views.BaseAdminView,BaseSetting)
Copy the code

Of course, if you have multiple apps, you only need to modify in one app.

What! Ugly name and footer? To change!

class GlobaSetting(object):
    site_title = "Alpaca"   # set the title
    site_footer = "The Company of Alpaca"  # set footer
    menu_style = "accordion" # Convert the list on the left to indent form

xadmin.site.register(xadmin.views.CommAdminView,GlobaSetting)
Copy the code

Yeah, that’s cool

App list for English too ugly!

/polls/apps.py

from django.apps import AppConfig


class PollsConfig(AppConfig):
    name = 'polls'
    verbose_name ="Application"
Copy the code
/polls/init.py

default_app_config = "polls.apps.PollsConfig"
Copy the code

Please see the error here

There is an error here because the version I typed before seems to be the version

I can’t get into superuser

Here we look at his error and enter the line

Change the code as follows, because the previous match was \n

Since \n fails to match, we can program ‘\><‘