""" Django settings for ORM project. Generated by 'django-admin startproject' using Django 1.10.5. For more information on this file, see https://docs.djangoproject.com/en/1.10/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.10/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 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.10/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '-pasr(osd7j9maaiqp0eibz1_v01&0b5hco+1sr*s1yy#ip)1!' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'app01', ] 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', ] ROOT_URLCONF = 'ORM.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 = 'ORM.wsgi.application' # Database # https://docs.djangoproject.com/en/1.10/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Password validation # https://docs.djangoproject.com/en/1.10/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.10/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.10/howto/static-files/ STATIC_URL = '/static/'
1. ALLOWED_HOSTSpython
DEBUG = Truesql
ALLOWED_HOSTS = []django
默认为一个空列表,表明此Django网站能够能够提供的主机/域名的字符串列表。当DEUG = True 和 ALLOWED_HOSTS 是空的时候,默认将对本机('localhost')进行验证session
2.INSTALLED_APPSapp
INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'app01', ]
django.contrib.admin —— 管理站点。
django.contrib.auth —— 认证系统。
django.contrib.contenttypes —— 用于内容类型的框架。
django.contrib.sessions —— 会话框架。
django.contrib.messages —— 消息框架。
django.contrib.staticfiles —— 管理静态文件的框架。
app01 是建立应用app的名字,若是项目建立了app则必需要添加app的名字框架
3.MIDDLEWARE_CLASSESide
一个django 用到的中间件 class 名称的 tuple. 参阅 middleware 文档.网站
4.ROOT_URLCONFui
默认值: Not definedthis
一个字符串,表示你的根 URLconf 的模块名. 举例来讲:"mydjangoapps.urls".
5.TEMPLATE_DIRS
默认值: () (空的 tuple)
模板源文件目录列表,按搜索顺序. 注意要使用 Unix-风格的前置斜线(即'/')
6.WSGI_APPLICATION
WSGI_APPLICATION 所指定的即为 wsgi.py 中的全局变量 application。在 get_wsgi_application() 中实例化了 WSGIHandler, 并没有其余操做.
7.STATIC_ROOT
运行上边提到的命令:python manage.py collectstatic 以后静态文件将要复制到的目录,这个目录只有在运行collectstatic时候才会用到,不能想固然的觉得这个目录和MEDIA_ROOT的做用是相同的,不然在开发环境的时候可能一直没法找到静态文件。
8.STATIC_URL
设置的static file的起始url,这个只是在template里边引用到,这个参数和MEDIA_URL的含义相同。
9.STATICFILES_DIRS
和TEMPLATE_DIRS的含义差很少,就是除了各个app的static目录之外还须要管理的静态文件设置,好比项目的公共文件差很少。
10.AUTH_USER_MODEL
自从django 1.5以后, 用户能够自定义User model了, 若是须要外键使用user model