Django comes back office systems

1. Preparation:

1-1. Creating django projects and applications
1-2 modify settings.py configuration file:
#应用配置:
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'app01.apps.App01Config',
]

#数据库配置:
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'myproject',
        'HOST': '127.0.0.1',
        'PORT':3306,
        'USER':'root',
        'PASSWORD':'1234'
    }
}   
    
#时间和语言相关配置
LANGUAGE_CODE = 'zh-Hans'   # 默认是英文
TIME_ZONE = 'Asia/Shanghai'    # 时区设置
USE_I18N = True
USE_L10N = True
USE_TZ = False       # 日期格式设置
init file under 1-3. project
import pymysql
pymysql.install_as_MySQLdb()
Create a class under models.py 1-4. Current applications
from django.db import models

# Create your models here.

class Author(models.Model): 
    name=models.CharField( max_length=32)
    age=models.IntegerField() 

    def __str__(self):
        return self.name
1-5. Admin.py configuration files in the current application
from django.contrib import admin
from app01 import models

# Register your models here.

admin.site.register(models.Author)
1-6. Executed the synchronization instruction
python manage.py makemigrations
python manage.py migrate

1. Create a superuser

python manage.py createsuperuser
Enter the user name password can not enter the mailbox

2. Log System

Start project, and then enter in your browser: http://127.0.0.1:8000/admin/
Enter your user name and password

3. related operations

Guess you like

Origin www.cnblogs.com/xiaomage666/p/11234508.html