Django settings介绍

it2022-05-07  4

""" Django settings for macboy project. Generated by 'django-admin startproject' using Django 1.11.15. For more information on this file, see https://docs.djangoproject.com/en/1.11/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os# 项目根目录路径 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'sp!(f!mohjdddwqnb1z=3p7x6*4x4&pk84&7ojwe_@pu-mk2j+f3i' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True # debug模式 上线前要关闭 ALLOWED_HOSTS = [] # 上线前写允许访问的服务器ip地址 # Application definition # app注册 INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog', # blog app名称 也可以写成 'blog.apps.BlogConfig', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', #'django.middleware.csrf.CsrfViewMiddleware', # 关闭csrf 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] # 项目总入口路由系统 ROOT_URLCONF = 'macboy.urls' # 页面模板 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', ], }, }, ] WSGI_APPLICATION = 'macboy.wsgi.application' # Database # https://docs.djangoproject.com/en/1.11/ref/settings/#databases # 默认数据库连接 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } }# mysql数据库连接'''DATABASES = {'default': {'ENGINE': 'django.db.backends.mysql', 'NAME': DB_DATABASE, 'USER': DB_USER, 'PASSWORD': DB_PASSWORD, 'HOST': DB_HOST, 'PORT': DB_PORT, }} # Password validation # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators 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', }, ] # Internationalization # https://docs.djangoproject.com/en/1.11/topics/i18n/ LANGUAGE_CODE = 'zh_Hans' # 汉语 TIME_ZONE = 'Asia/Shanghai' # 时区 USE_I18N = True USE_L10N = True USE_TZ = False # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ STATIC_URL = '/static/' # 别名 浏览器访问静态文件的URL前缀 STATICFILES_DIRS = ( os.path.join(BASE_DIR, "static"), # 静态文件真实路径 注意是一个列表! ) # STATIC_ROOT = os.path.join(BASE_DIR, "static1")

 

转载于:https://www.cnblogs.com/icemonkey/p/10505607.html


最新回复(0)