项目的总配置文件
里面包含了数据库、Web应用、时间等各种配置
-根目录:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-安全码:
SECRET_KEY = ‘(5on3gavpqx!z!-dewv4tt)$)b&#l%@+&^kfvn%g2pqptguvav‘
-调试:
DEBUG = True
-如果填入localhost则只允许localhost方式访问
ALLOWED_HOSTS = []
-已安装的应用:将来我们要把自己安装的应用名写到这里
INSTALLED_APPS = [
‘django.contrib.admin‘,
‘django.contrib.auth‘,
‘django.contrib.contenttypes‘,
‘django.contrib.sessions‘,
‘django.contrib.messages‘,
‘django.contrib.staticfiles‘,
]
-中间件
MIDDLEWARE = [
‘django.middleware.security.SecurityMiddleware‘,
‘django.contrib.sessions.middleware.SessionMiddleware‘,
‘django.middleware.common.CommonMiddleware‘,
‘django.middleware.csrf.CsrfViewMiddleware‘,
‘django.contrib.auth.middleware.AuthenticationMiddleware‘,
‘django.contrib.messages.middleware.MessageMiddleware‘,
‘django.middleware.clickjacking.XFrameOptionsMiddleware‘,
]
-指向(url的根文件)
ROOT_URLCONF = ‘myblog.urls‘
-模板:html文件
TEMPLATES = [
{
‘BACKEND‘: ‘django.template.backends.django.DjangoTemplates‘,
‘DIRS‘:[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‘,
],
},
},
]
-不管他
WSGI_APPLICATION = ‘myblog.wsgi.application‘
-数据库配置
DATABASES = {
‘default‘: {
‘ENGINE‘: ‘django.db.backends.sqlite3‘,
‘NAME‘: os.path.join(BASE_DIR, ‘db.sqlite3‘),
}
}
-时间语言
LANGUAGE_CODE = ‘en-us‘
TIME_ZONE = ‘UTC‘
USE_I18N = True
USE_L10N = True
USE_TZ = True
-静态文件的地址
STATIC_URL = ‘/static/‘