项目根目录:
1 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
项目安全码:
1 | SECRET_KEY = ')b)3406p#v$u4ft(*=0*w1l*=0v0ixdrey)mmcd2uf#(x' |
DEBUG调试:
不要在实际生产中打开debug
允许访问的主机:
*是代表允许所有主机访问
已安装的应用:
123456789 | INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'myapp'] |
如果我们自己创建了应用需要把应用名添加到这个地方
中间件(工具集):
12345678910 | MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',] |
url根文件:
1 | ROOT_URLCONF = 'myproject.urls' |
模板配置:
123456789101112131415大专栏 django配置settings详解br/> | TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': ['appfront/dist'], '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', ], }, },] |
数据库配置:
123456789 | DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'myproject', 'USER': 'root', 'PASSWORD': 'inspur', 'HOST': 'localhost', }} |
https://docs.djangoproject.com/en/1.11/ref/settings/#databases 这个网址里有不同的数据的配置方式
密码认证:
1234567891011121314 | AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', },] |
国际化:
123456789 | LANGUAGE_CODE = 'en-us'TIME_ZONE = 'UTC'USE_I18N = TrueUSE_L10N = TrueUSE_TZ = True |
静态文件地址: