|
- """
- Copyright (c) Django Software Foundation and individual contributors.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- 3. Neither the name of Django nor the names of its contributors may be used
- to endorse or promote products derived from this software without
- specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Django settings for backend project.
-
- Generated by 'django-admin startproject' using Django 3.0.3.
-
- For more information on this file, see
- https://docs.djangoproject.com/en/3.0/topics/settings/
-
- For the full list of settings and their values, see
- https://docs.djangoproject.com/en/3.0/ref/settings/
- """
-
- import os
- from utils.config_utils import ConfigInstance
-
- # 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/3.0/howto/deployment/checklist/
-
- # SECURITY WARNING: keep the secret key used in production secret!
- SECRET_KEY = '42n5q5ki33%^l(0^63q7%(#sd0v#n^_gxkld-c*g_#1#ewrf1f'
-
- # SECURITY WARNING: don't run with debug turned on in production!
- DEBUG = ConfigInstance.conf_django_debug()
-
- ALLOWED_HOSTS = ['*']
-
- SESSION_COOKIE_AGE = 60 * ConfigInstance.conf_user_expiration_time()
-
- CACHES = {
- 'default': {
- 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', # 指定缓存使用的引擎
- 'LOCATION': 'unique-snowflake', # 写在内存中的变量的唯一值
- 'TIMEOUT': None, # 缓存超时时间(默认为300秒,None表示永不过期)
- 'OPTIONS': {
- 'MAX_ENTRIES': 300, # 最大缓存记录的数量(默认300)
- 'CULL_FREQUENCY': 3, # 缓存到达最大个数之后,剔除缓存个数的比例,即:1/CULL_FREQUENCY(默认3)
- }
- }
- }
-
- # Application definition
-
- INSTALLED_APPS = [
- 'django.contrib.admin',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
- 'corsheaders',
- ]
-
- MIDDLEWARE = [
- 'django.middleware.security.SecurityMiddleware',
- 'django.contrib.sessions.middleware.SessionMiddleware',
- 'corsheaders.middleware.CorsMiddleware',
- 'django.middleware.common.CommonMiddleware',
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.contrib.messages.middleware.MessageMiddleware',
- 'django.middleware.clickjacking.XFrameOptionsMiddleware',
- 'django.middleware.common.CommonMiddleware',
- 'backend.data_provider.session_mdw.session_middleware'
- ]
-
- ROOT_URLCONF = 'backend.urls'
-
- # 跨域增加忽略
- SESSION_COOKIE_SAMESITE = None
- CORS_ALLOW_CREDENTIALS = True
- CORS_ORIGIN_ALLOW_ALL = True
- CORS_ORIGIN_WHITELIST = (
- 'http://127.0.0.1',
- 'http://localhost',
- )
-
- CORS_ALLOW_METHODS = (
- 'DELETE',
- 'GET',
- 'OPTIONS',
- 'PATCH',
- 'POST',
- 'PUT',
- 'VIEW',
- )
-
- CORS_ALLOW_HEADERS = (
- 'XMLHttpRequest',
- 'X_FILENAME',
- 'accept-encoding',
- 'authorization',
- 'content-type',
- 'dnt',
- 'origin',
- 'user-agent',
- 'x-csrftoken',
- 'x-requested-with',
- 'Pragma',
- )
-
- TEMPLATES = [
- {
- 'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'DIRS': [
- os.path.join(BASE_DIR, 'frontend'),
- ],
- '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 = 'backend.wsgi.application'
-
-
- # Database
- # https://docs.djangoproject.com/en/3.0/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/3.0/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/3.0/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/3.0/howto/static-files/
-
- STATIC_URL = os.path.join(BASE_DIR, '/static/')
- STATICFILES_DIRS = [
- os.path.join(BASE_DIR + '/frontend/static')
- ]
|