settings.py 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. # coding=utf-8
  2. """
  3. Django settings for markwin project.
  4. Generated by 'django-admin startproject' using Django 2.2.5.
  5. For more information on this file, see
  6. https://docs.djangoproject.com/en/2.2/topics/settings/
  7. For the full list of settings and their values, see
  8. https://docs.djangoproject.com/en/2.2/ref/settings/
  9. """
  10. import os, 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.2/howto/deployment/checklist/
  15. # SECURITY WARNING: keep the secret key used in production secret!
  16. SECRET_KEY = 'c+)5afbc(m&qe^8t7gc54w6f-*==b2(l0(8rqef-cbwtv*3n$w'
  17. # SECURITY WARNING: don't run with debug turned on in production!
  18. DEBUG = True
  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. 'corsheaders',
  29. 'rest_framework',
  30. 'rest_framework_jwt',
  31. 'django_filters',
  32. 'apps.account',
  33. 'apps.foundation',
  34. 'apps.usedvehicle',
  35. 'apps.images',
  36. 'apps.vehicle',
  37. 'apps.product',
  38. 'apps.activity',
  39. # 'apps.employee',
  40. # 'apps.option',
  41. # 'apps.package',
  42. # 'apps.package_order',
  43. # 'apps.pay',
  44. # 'apps.poster',
  45. # 'apps.activity',
  46. # 'apps.message',
  47. # 'apps.vehicle_model',
  48. # 'apps.customer',
  49. # 'apps.vehicle_order',
  50. # 'apps.recommend',
  51. # 'apps.config',
  52. # 'apps.sales_advisor',
  53. # 'apps.commission_order',
  54. # 'apps.commission_log',
  55. # 'apps.cashout_order',
  56. # 'apps.sms',
  57. # 'apps.collection',
  58. # 'apps.WechatApplet',
  59. # 'apps.WechatTp',
  60. # 'apps.api',
  61. # 'apps.xgjsms',
  62. # 'apps.coupon',
  63. # 'apps.statistics',
  64. # 'apps.points_order',
  65. # 'apps.points_log'
  66. ]
  67. MIDDLEWARE = [
  68. 'django.middleware.security.SecurityMiddleware',
  69. 'django.contrib.sessions.middleware.SessionMiddleware',
  70. 'django.middleware.common.CommonMiddleware',
  71. 'django.middleware.csrf.CsrfViewMiddleware',
  72. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  73. 'django.contrib.messages.middleware.MessageMiddleware',
  74. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  75. 'corsheaders.middleware.CorsMiddleware',
  76. ]
  77. CORS_ALLOW_CREDENTIALS = True # 允许携带cookie
  78. CORS_ORIGIN_ALLOW_ALL = True
  79. CORS_ALLOW_METHODS = (
  80. 'DELETE',
  81. 'GET',
  82. 'OPTIONS',
  83. 'PATCH',
  84. 'POST',
  85. 'PUT',
  86. 'VIEW',
  87. )
  88. CORS_ALLOW_HEADERS = (
  89. 'XMLHttpRequest',
  90. 'X_FILENAME',
  91. 'accept-encoding',
  92. 'authorization',
  93. 'content-type',
  94. 'dnt',
  95. 'origin',
  96. 'token',
  97. 'user-agent',
  98. 'x-csrftoken',
  99. 'x-requested-with',
  100. 'Pragma',
  101. )
  102. ROOT_URLCONF = 'shop.urls'
  103. AUTH_USER_MODEL = "account.User"
  104. AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.AllowAllUsersModelBackend']
  105. TEMPLATES = [
  106. {
  107. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  108. 'DIRS': [],
  109. 'APP_DIRS': True,
  110. 'OPTIONS': {
  111. 'context_processors': [
  112. 'django.template.context_processors.debug',
  113. 'django.template.context_processors.request',
  114. 'django.contrib.auth.context_processors.auth',
  115. 'django.contrib.messages.context_processors.messages',
  116. ],
  117. },
  118. },
  119. ]
  120. WSGI_APPLICATION = 'shop.wsgi.application'
  121. # Database
  122. # https://docs.djangoproject.com/en/2.2/ref/settings/#databases
  123. DATABASES = {
  124. 'default': {
  125. 'ENGINE': 'django.db.backends.mysql',
  126. 'NAME': 'lhyt_shop',
  127. 'USER': 'carwin',
  128. 'PASSWORD': 'carwin!@#',
  129. 'HOST': '192.168.2.55',
  130. 'PORT': 3306,
  131. }
  132. }
  133. # Password validation
  134. # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
  135. AUTH_PASSWORD_VALIDATORS = [
  136. {
  137. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  138. },
  139. {
  140. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  141. },
  142. {
  143. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  144. },
  145. {
  146. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  147. },
  148. ]
  149. UNKNOW = 0
  150. FEMALE = 1
  151. MALE = 2
  152. GENDER_CHOICES = (
  153. (UNKNOW, u'未知'),
  154. (FEMALE, u'女'),
  155. (MALE, u'男'),
  156. )
  157. DEFAULT = 0
  158. PASS = 1
  159. REJECT = 2
  160. CHECK_STATE_CHOICES = (
  161. (DEFAULT, u'未审核'),
  162. (PASS, u'已通过'),
  163. (REJECT, u'未通过'),
  164. )
  165. # Internationalization
  166. # https://docs.djangoproject.com/en/2.2/topics/i18n/
  167. LANGUAGE_CODE = 'zh-hans'
  168. TIME_ZONE = 'Asia/Shanghai'
  169. USE_I18N = True
  170. USE_L10N = True
  171. USE_TZ = False
  172. # Static files (CSS, JavaScript, Images)
  173. # https://docs.djangoproject.com/en/2.2/howto/static-files/
  174. STATIC_URL = '/static/'
  175. MEDIA_URL = '/up/'
  176. MEDIA_ROOT = os.path.join(BASE_DIR, "uis/up/")
  177. UIS_URL = '/'
  178. UIS_ROOT = os.path.join(BASE_DIR, "uis/")
  179. SERVER_DOMAIN = 'https://xapp.aiche360.cn'
  180. JWT_AUTH = {
  181. 'JWT_EXPIRATION_DELTA': datetime.timedelta(days=30),
  182. 'JWT_REFRESH_EXPIRATION_DELTA': datetime.timedelta(days=360),
  183. 'JWT_ALLOW_REFRESH': True,
  184. }
  185. REST_FRAMEWORK = {
  186. 'DEFAULT_PERMISSION_CLASSES': (
  187. 'rest_framework.permissions.AllowAny',
  188. ),
  189. 'DEFAULT_AUTHENTICATION_CLASSES': (
  190. 'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
  191. #'rest_framework.authentication.SessionAuthentication',
  192. #'rest_framework.authentication.BasicAuthentication',
  193. ),
  194. 'DEFAULT_PARSER_CLASSES': (
  195. 'rest_framework.parsers.JSONParser',
  196. 'rest_framework.parsers.FormParser',
  197. 'rest_framework.parsers.MultiPartParser'
  198. ),
  199. 'DEFAULT_RENDERER_CLASSES': (
  200. 'rest_framework.renderers.JSONRenderer',
  201. # 'rest_framework.renderers.BrowsableAPIRenderer',
  202. ),
  203. 'DEFAULT_FILTER_BACKENDS': (
  204. 'django_filters.rest_framework.DjangoFilterBackend',
  205. ),
  206. #'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
  207. 'DEFAULT_PAGINATION_CLASS': 'utils.pagination.CustomPagination',
  208. #'EXCEPTION_HANDLER': 'rest_framework.views.exception_handler',
  209. 'EXCEPTION_HANDLER': 'utils.handler.custom_exception_handler',
  210. 'PAGE_SIZE': 10,
  211. 'DATETIME_FORMAT': "%Y-%m-%d %H:%M:%S",
  212. 'NON_FIELD_ERRORS_KEY': "error", # 序列化器错误KEY名称
  213. }
  214. # 导入本地设置
  215. try:
  216. from shop.local_settings import *
  217. except ImportError:
  218. pass