Django基本文件配置
1、setting.py
(1) ALLOWED_HOSTS = ['*']
(2) INSTALLED_APPS = ['app_name']
(3) TEMPLATES 中的 'DIRS': [os.path.join(BASE_DIR, 'templates')]
(4) 数据库
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'db', 'USER': 'root', 'PASSWORD': '123456', 'HOST': 'localhost', 'PORT': '3306', } }
(5)语言切换
# 英文 LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC' # 中文 LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
(6)STATICFILES_DIRS
STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), ]
(7)MEDIA_ROOT
MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media').replace('\\', '/')
kingrain送给读者的话:Everthing isn't getting along well,your efforts paid off!