settings.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. """
  2. Django settings for bigdataAPI 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. import datetime
  11. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  12. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  13. # Quick-start development settings - unsuitable for production
  14. # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
  15. # SECURITY WARNING: keep the secret key used in production secret!
  16. SECRET_KEY = '$rs)*w)9gh)nkf1=@r$2xguf1b(qz8ba!%hm8lwt54ti3_da^b'
  17. # SECURITY WARNING: don't run with debug turned on in production!
  18. DEBUG = False
  19. ALLOWED_HOSTS = ['*']
  20. # Application definition
  21. INSTALLED_APPS = [
  22. 'django.contrib.admin',
  23. 'django.contrib.auth',
  24. 'django.contrib.contenttypes',
  25. 'django.contrib.sessions',
  26. 'django.contrib.messages',
  27. 'django.contrib.staticfiles',
  28. 'rest_framework',
  29. 'rest_framework_jwt',
  30. 'apps.UserApp',
  31. 'apps.IOTCard',
  32. 'apps.PestAnalysis',
  33. 'apps.Equipment',
  34. ]
  35. MIDDLEWARE = [
  36. 'django.middleware.security.SecurityMiddleware',
  37. 'django.contrib.sessions.middleware.SessionMiddleware',
  38. 'django.middleware.common.CommonMiddleware',
  39. # 'django.middleware.csrf.CsrfViewMiddleware',
  40. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  41. 'django.contrib.messages.middleware.MessageMiddleware',
  42. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  43. ]
  44. ROOT_URLCONF = 'bigdataAPI.urls'
  45. TEMPLATES = [
  46. {
  47. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  48. 'DIRS': [],
  49. 'APP_DIRS': True,
  50. 'OPTIONS': {
  51. 'context_processors': [
  52. 'django.template.context_processors.debug',
  53. 'django.template.context_processors.request',
  54. 'django.contrib.auth.context_processors.auth',
  55. 'django.contrib.messages.context_processors.messages',
  56. ],
  57. },
  58. },
  59. ]
  60. WSGI_APPLICATION = 'bigdataAPI.wsgi.application'
  61. # Database
  62. # https://docs.djangoproject.com/en/2.1/ref/settings/#databases
  63. # USER_CONFIG = {
  64. # 'mysql': {
  65. # 'host': 'localhost',
  66. # 'user': 'root',
  67. # 'pwd': 'yfkj@6020',
  68. # 'port': 3306
  69. # },
  70. # 'mongodb': {
  71. # 'host': 'localhost',
  72. # 'user': 'root',
  73. # 'pwd': 'yfkj@6020',
  74. # 'port': 27017
  75. # }
  76. # }
  77. USER_CONFIG = {
  78. 'mysql': {
  79. 'host': 'localhost',
  80. 'user': 'root',
  81. 'pwd': 'yfkj@6020',
  82. 'port': 61882
  83. },
  84. 'mongodb': {
  85. 'host': 'localhost',
  86. 'user': 'root',
  87. 'pwd': 'yfkj@6020',
  88. 'port': 57017
  89. }
  90. }
  91. DATABASES = {
  92. 'default': {
  93. 'ENGINE': 'django.db.backends.mysql',
  94. 'NAME': 'bigdata_api',
  95. 'USER': 'api',
  96. 'PASSWORD': 'yfkj@6020',
  97. 'HOST': '127.0.0.1',
  98. 'PORT': 61882,
  99. 'OPTIONS': {'charset': 'utf8mb4'}
  100. }
  101. }
  102. # Password validation
  103. # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
  104. AUTH_PASSWORD_VALIDATORS = [
  105. {
  106. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  107. },
  108. {
  109. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  110. },
  111. {
  112. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  113. },
  114. {
  115. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  116. },
  117. ]
  118. # Internationalization
  119. # https://docs.djangoproject.com/en/2.1/topics/i18n/
  120. LANGUAGE_CODE = 'zh-Hans'
  121. TIME_ZONE = 'Asia/Shanghai'
  122. USE_I18N = True
  123. USE_L10N = True
  124. USE_TZ = False
  125. # Static files (CSS, JavaScript, Images)
  126. # https://docs.djangoproject.com/en/2.1/howto/static-files/
  127. STATIC_URL = '/static/'
  128. AUTH_USER_MODEL = 'UserApp.MyUser'
  129. REST_FRAMEWORK = {
  130. # 全局配置异常模块
  131. 'EXCEPTION_HANDLER': 'utils.exception.custom_exception_handler',
  132. # 修改默认返回JSON的renderer的类
  133. 'DEFAULT_RENDERER_CLASSES': (
  134. 'utils.rendererresponse.CustomRender',
  135. ),
  136. 'DEFAULT_THROTTLE_RATES': {
  137. 'devicelist': '1/m',
  138. 'devicedetail': '1/m'
  139. }
  140. }
  141. JWT_AUTH = {
  142. 'JWT_EXPIRATION_DELTA': datetime.timedelta(days=1),
  143. }
  144. CACHES = {
  145. 'default': {
  146. 'BACKEND': 'uwsgicache.UWSGICache',
  147. # and optionally, if you use a different cache name
  148. 'LOCATION': 'foobar'
  149. }
  150. }