| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- """
- Django settings for gameHall project.
- Generated by 'django-admin startproject' using Django 2.1.3.
- For more information on this file, see
- https://docs.djangoproject.com/en/2.1/topics/settings/
- For the full list of settings and their values, see
- https://docs.djangoproject.com/en/2.1/ref/settings/
- """
- import os
- # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
- import sys
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
- sys.path.insert(0, os.path.join(BASE_DIR, 'gameHall'))
- # 把extra_apps文件夹添加到搜索目录中
- sys.path.insert(0, os.path.join(BASE_DIR, 'extra_apps'))
- # Quick-start development settings - unsuitable for production
- # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
- # SECURITY WARNING: keep the secret key used in production secret!
- SECRET_KEY = 'm02=(nifvtbsq+v&s(%_ft=@&_p+tg7s3(^fchb$m-pvb4+w6o'
- # 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',
- 'rest_framework',
- 'rest_framework.authtoken',
- # 解决跨域
- 'corsheaders',
- 'xadmin',
- 'crispy_forms', # 注意crispy_forms之间是下划线隔开,不是横线
- 'reversion', # 添加(可选)
- 'app'
- ]
- MIDDLEWARE = [
- 'django.middleware.security.SecurityMiddleware',
- 'django.contrib.sessions.middleware.SessionMiddleware',
- 'django.middleware.common.CommonMiddleware',
- 'corsheaders.middleware.CorsMiddleware',
- # 测试关掉post
- # 'django.middleware.csrf.CsrfViewMiddleware',
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.contrib.messages.middleware.MessageMiddleware',
- 'django.middleware.clickjacking.XFrameOptionsMiddleware',
- ]
- # REST_FRAMEWORK的配置
- REST_FRAMEWORK = {
- # 'DEFAULT_PERMISSION_CLASSES': (
- # 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly',
- # 'rest_framework.permissions.IsAuthenticated',
- # 'rest_framework.permissions.AllowAny',
- # ),
- # 'DEFAULT_AUTHENTICATION_CLASSES': (
- # 'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
- # 'rest_framework.authentication.SessionAuthentication',
- # 'rest_framework.authentication.TokenAuthentication',
- # 'rest_framework.authentication.BasicAuthentication',
- # ),
- # 分页显示
- 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
- 'PAGE_SIZE': 10,
- # 配置过滤
- 'DEFAULT_FILTER_BACKENDS': (
- 'django_filters.rest_framework.DjangoFilterBackend', 'rest_framework.filters.SearchFilter'),
- }
- ROOT_URLCONF = 'gameHall.urls'
- import datetime
- JWT_AUTH = {
- 'JWT_AUTH_HEADER_PREFIX': 'Token',
- 'JWT_EXPIRATION_DELTA': datetime.timedelta(days=30),
- 'JWT_REFRESH_EXPIRATION_DELTA': datetime.timedelta(days=365),
- }
- 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 = 'gameHall.wsgi.application'
- # Database
- # https://docs.djangoproject.com/en/2.1/ref/settings/#databases
- DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
- }
- # 'default': {
- # 'ENGINE': 'django.db.backends.mysql',
- # 'NAME': 'gamehall',
- # 'HOST': 'localhost',
- # 'PORT': '3306',
- # 'USER': 'root',
- # 'PASSWORD': '123456',
- # },
- # # 开发
- # 'dev': {
- # 'ENGINE': 'django.db.backends.mysql',
- # 'NAME': 'gamehall',
- # 'HOST': 'localhost',
- # 'PORT': '3306',
- # 'USER': 'root',
- # 'PASSWORD': '123',
- # },
- # # 正式
- # 'pro': {
- # 'ENGINE': 'django.db.backends.mysql',
- # 'NAME': 'gamehall',
- # 'HOST': 'localhost',
- # 'PORT': '3306',
- # 'USER': 'root',
- # 'PASSWORD': '123456',
- # },
- }
- # DATABASE_ROUTERS = ['gameHall.database_router.DatabaseAppsRouter']
- # DATABASE_APPS_MAPPING = {
- # # example:
- # # 'app_name':'database_name',
- # 'app': 'default',
- # # 正式环境切换
- # # 'app': 'pro',
- # }
- # Password validation
- # https://docs.djangoproject.com/en/2.1/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/2.1/topics/i18n/
- LANGUAGE_CODE = 'zh-Hans'
- TIME_ZONE = 'Asia/Shanghai'
- USE_I18N = True
- USE_L10N = True
- USE_TZ = True
- # Static files (CSS, JavaScript, Images)
- # https://docs.djangoproject.com/en/2.1/howto/static-files/
- STATIC_URL = '/static/'
- CORS_ALLOW_CREDENTIALS = True
- CORS_ORIGIN_ALLOW_ALL = True
- 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',
- )
- MEDIA_URL = "/media/"
- MEDIA_ROOT = os.path.join(BASE_DIR, "media")
- CKEDITOR_UPLOAD_PATH = "article_images"
|