标签:back 时间 session admin lang 时区设置 info 配置 日期格
#应用配置:
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 # 日期格式设置
import pymysql
pymysql.install_as_MySQLdb()
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
from django.contrib import admin
from app01 import models
# Register your models here.
admin.site.register(models.Author)
python manage.py makemigrations
python manage.py migrate
标签:back 时间 session admin lang 时区设置 info 配置 日期格
原文地址:https://www.cnblogs.com/xiaomage666/p/11234508.html