settings.py 6.5 KB

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