django 配置文件settings.py 设置模板

INSTALLED_APPS = [
  'django.contrib.admin',
  'django.contrib.auth',
  'django.contrib.contenttypes',
  'django.contrib.sessions',
  'django.contrib.messages',
  'django.contrib.staticfiles',
  # 激活app
  'Myapp'
]
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR,'htmls')],#模板文件夹名称为htmls
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]  
# 更改数据库连接为mysql
DATABASES = {
  'default': {
    'ENGINE': 'django.db.backends.mysql',
    'HOST' : 'localhost',
    'PORT' : 3306,
    'NAME' : 'mysql',
    'USER': 'root',
    'PASSWORD' : '123456'
  }
}
# 汉语与时区
  
LANGUAGE_CODE = 'zh-hans'
  
TIME_ZONE = 'Asia/Shanghai'
  
# 静态文件夹路径
STATIC_URL = '/static/'
  
STATICFILES_DIRS = [
  os.path.join(BASE_DIR,'static'),
]
posted @ 2019-12-20 09:50  y0um  阅读(436)  评论(0编辑  收藏  举报

新人优惠服务器