settings.py 6.4 KB

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