local_settings.py 3.5 KB

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