settings.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. """
  2. Django settings for AnsjerPush project.
  3. Generated by 'django-admin startproject' using Django 2.1.4.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/2.1/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/2.1/ref/settings/
  8. """
  9. import os
  10. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  11. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  12. # Quick-start development settings - unsuitable for production
  13. # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
  14. # SECURITY WARNING: keep the secret key used in production secret!
  15. SECRET_KEY = '$2hf5g$a%_^kk0-l25l$!o5)yc=dvtnfpc8(+$rh4fq4twa_xx'
  16. # SECURITY WARNING: don't run with debug turned on in production!
  17. DEBUG = True
  18. ALLOWED_HOSTS = ["*"]
  19. # Application definition
  20. INSTALLED_APPS = [
  21. 'django.contrib.admin',
  22. 'django.contrib.auth',
  23. 'django.contrib.contenttypes',
  24. 'django.contrib.sessions',
  25. 'django.contrib.messages',
  26. 'django.contrib.staticfiles',
  27. 'corsheaders',
  28. 'imagekit',
  29. 'Model'
  30. ]
  31. MIDDLEWARE = [
  32. 'corsheaders.middleware.CorsMiddleware',
  33. 'django.middleware.security.SecurityMiddleware',
  34. 'django.contrib.sessions.middleware.SessionMiddleware',
  35. 'django.middleware.common.CommonMiddleware',
  36. # 'django.middleware.csrf.CsrfViewMiddleware',
  37. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  38. 'django.contrib.messages.middleware.MessageMiddleware',
  39. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  40. ]
  41. ROOT_URLCONF = 'AnsjerPush.urls'
  42. TEMPLATES = [
  43. {
  44. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  45. 'DIRS': [os.path.join(BASE_DIR, 'templates')]
  46. ,
  47. 'APP_DIRS': True,
  48. 'OPTIONS': {
  49. 'context_processors': [
  50. 'django.template.context_processors.debug',
  51. 'django.template.context_processors.request',
  52. 'django.contrib.auth.context_processors.auth',
  53. 'django.contrib.messages.context_processors.messages',
  54. ],
  55. },
  56. },
  57. ]
  58. WSGI_APPLICATION = 'AnsjerPush.wsgi.application'
  59. # Database
  60. # https://docs.djangoproject.com/en/2.1/ref/settings/#databases
  61. # formal
  62. # DATABASE_DATA = 'Ansjer81'
  63. # SERVER_HOST = 'localhost'
  64. # DATABASES_USER = 'ansjer'
  65. # DATABASES_PASS = '1234'
  66. # test
  67. DATABASE_DATA = 'AnsjerTest'
  68. SERVER_HOST = '13.56.215.252'
  69. DATABASES_USER = 'ansjer'
  70. DATABASES_PASS = '1234'
  71. DATABASES = {'default': {
  72. 'ENGINE': 'django.db.backends.mysql',
  73. 'NAME': DATABASE_DATA,
  74. 'USER': DATABASES_USER,
  75. 'PASSWORD': DATABASES_PASS,
  76. 'HOST': SERVER_HOST,
  77. 'PORT': '3306',
  78. 'OPTIONS': {'charset': 'utf8mb4', 'use_unicode': True, 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"},
  79. 'AUTOCOMMIT': True
  80. }}
  81. # Password validation
  82. # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
  83. AUTH_PASSWORD_VALIDATORS = [
  84. {
  85. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  86. },
  87. {
  88. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  89. },
  90. {
  91. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  92. },
  93. {
  94. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  95. },
  96. ]
  97. # Internationalization
  98. # https://docs.djangoproject.com/en/2.1/topics/i18n/
  99. LANGUAGE_CODE = 'en-us'
  100. TIME_ZONE = 'UTC'
  101. USE_I18N = True
  102. USE_L10N = True
  103. USE_TZ = True
  104. # Static files (CSS, JavaScript, Images)
  105. # https://docs.djangoproject.com/en/2.1/howto/static-files/
  106. STATIC_URL = '/static/'
  107. # 跨域增加忽略
  108. CORS_ALLOW_CREDENTIALS = True
  109. CORS_ORIGIN_ALLOW_ALL = True
  110. CORS_ORIGIN_WHITELIST = ('*')
  111. CORS_ALLOW_METHODS = (
  112. 'DELETE',
  113. 'GET',
  114. 'OPTIONS',
  115. 'PATCH',
  116. 'POST',
  117. 'PUT',
  118. 'VIEW',
  119. )
  120. CORS_ALLOW_HEADERS = (
  121. 'XMLHttpRequest',
  122. 'X_FILENAME',
  123. 'accept',
  124. 'accept-encoding',
  125. 'authorization',
  126. 'content-type',
  127. 'dnt',
  128. 'origin',
  129. 'user-agent',
  130. 'x-csrftoken',
  131. 'x-requested-with',
  132. 'Pragma',
  133. )