码迷,mamicode.com
首页 > 其他好文 > 详细

Django 配置文件 settings.py

时间:2017-12-27 14:18:39      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:url   request   utc   pos   ges   div   ssi   password   mysq   

1. dubug配置

DEBUG=False

2. 数据库配置

DATABASES = {
    ‘default‘: {
        ‘ENGINE‘: ‘django.db.backends.mysql‘,
        "NAME": "dbname",
        "USER": "root",
        "PASSWORD": "xxxx",
        "HOST": "192.168.11.166",
        "PORT":3316
    }
}

3. 模板

TEMPLATES = [
    {
        ‘BACKEND‘: ‘django.template.backends.django.DjangoTemplates‘,
        ‘DIRS‘: [os.path.join(BASE_DIR, ‘templates‘)]
        ,
        ‘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‘,
            ],
        },
    },
]

4. 静态文件

STATIC_URL = ‘/static/‘
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static"),
)

5. 时区设置

# LANGUAGE_CODE = ‘en-us‘
# TIME_ZONE = ‘UTC‘
LANGUAGE_CODE = ‘zh-hans‘
TIME_ZONE = ‘Asia/Shanghai‘
USE_I18N = True
USE_L10N = True
USE_TZ = False

6. session 配置

# 默认值: 1209600 (2周, 以秒计)
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_COOKIE_AGE = 30 * 60

7. 时间格式设置

DATETIME_FORMAT = ‘Y-m-d H:i:s‘
DATE_FORMAT = ‘Y-m-d‘

Django 配置文件 settings.py

标签:url   request   utc   pos   ges   div   ssi   password   mysq   

原文地址:https://www.cnblogs.com/lmx1002/p/8124633.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!