Django+Xadmin construction project

Part Django

  1. Create project

    django-admin startproject mysite #Create a mysite project
  2. Run easy server

    python runserver  #Welcome page
  3. Set system language and time

    //File name:
    LANGUAGE_CODE = 'zh-hans'
    TIME_ZONE = 'Asia/Shanghai'
  4. Set up MySQL database

    Create a database before changing the settings file

    ********Under project Add the following code to the file********
    import pymysql
    *************** file*********************
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'HOST': 'localhost',
            'PORT': '3306',
            'NAME': 'dadi',
            'USER': 'root',
            'PASSWORD': 'root',
  5. Database migration

    python migrate #Create database table according to file
  6. Create administrator account

    python createsuperuser

    So far, a Django project has been built, and the browser opens You can use the set administrator account to log in to the management background. APP has not been created yet. To create APP, run py in the project directory startapp app_name

Introducing xadmin

  1. Install xadmin

    pip install git+git://
  2. Set file

    import xadmin //Add this trip
    from django.conf import settings //Add this trip
    from django.conf.urls.static import static //Add this trip
    from django.urls import path
    urlpatterns = [
        path('admin/',, //Revision of this trip
  3. file

    import xadmin  //Add this trip
        'xadmin', //Add this trip
        'crispy_forms'  //Add this trip
  4. Execute database migration command again

    python migrate

    After the migration is completed, you can log in with the background management account you created before. At this time, you can see that the background interface has changed.

Tags: Django Database Python git

Posted on Sat, 30 Nov 2019 02:38:20 -0800 by fingerprn