settings.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. """
  2. Django settings for Django_test project.
  3. Generated by 'django-admin startproject' using Django 3.0.8.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/3.0/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/3.0/ref/settings/
  8. """
  9. import os
  10. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  11. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  12. # Quick-start development settings - unsuitable for production
  13. # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
  14. # SECURITY WARNING: keep the secret key used in production secret!
  15. SECRET_KEY = '4-0fer)tx1nnb@w$^3zyv13i6i)7*i(j=5b($ayd32t%5rbq+#'
  16. # SECURITY WARNING: don't run with debug turned on in production!
  17. DEBUG = True
  18. ALLOWED_HOSTS = []
  19. # Application definition
  20. INSTALLED_APPS = [
  21. 'django.contrib.admin',
  22. 'django.contrib.auth',
  23. 'django.contrib.contenttypes',
  24. 'django.contrib.sessions',
  25. 'django.contrib.messages',
  26. 'django.contrib.staticfiles',
  27. 'rest_framework',
  28. 'workreport',
  29. 'mptt',
  30. 'mptt_test',
  31. 'even_table',
  32. 'payment',
  33. 'basic',
  34. 'routes',
  35. ]
  36. MIDDLEWARE = [
  37. 'django.middleware.security.SecurityMiddleware',
  38. 'django.contrib.sessions.middleware.SessionMiddleware',
  39. 'django.middleware.common.CommonMiddleware',
  40. 'django.middleware.csrf.CsrfViewMiddleware',
  41. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  42. 'django.contrib.messages.middleware.MessageMiddleware',
  43. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  44. ]
  45. ROOT_URLCONF = 'Django_test.urls'
  46. TEMPLATES = [
  47. {
  48. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  49. 'DIRS': [os.path.join(BASE_DIR, 'templates')]
  50. ,
  51. 'APP_DIRS': True,
  52. 'OPTIONS': {
  53. 'context_processors': [
  54. 'django.template.context_processors.debug',
  55. 'django.template.context_processors.request',
  56. 'django.contrib.auth.context_processors.auth',
  57. 'django.contrib.messages.context_processors.messages',
  58. ],
  59. },
  60. },
  61. ]
  62. WSGI_APPLICATION = 'Django_test.wsgi.application'
  63. # Database
  64. # https://docs.djangoproject.com/en/3.0/ref/settings/#databases
  65. DATABASES = {
  66. 'default': {
  67. 'ENGINE': 'django.db.backends.mysql',
  68. # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
  69. 'NAME': 'linxa_django_demo',
  70. 'USER': 'root',
  71. 'PASSWORD': 'abc.123',
  72. # srv.test.linkerplus.com
  73. 'HOST': 'www.test.linkerplus.com',
  74. 'PORT': '3310',
  75. 'OPTIONS': {
  76. 'init_command': 'SET sql_mode="STRICT_TRANS_TABLES"',
  77. 'charset': 'utf8mb4'
  78. }
  79. }
  80. }
  81. # Password validation
  82. # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
  83. AUTH_PASSWORD_VALIDATORS = [
  84. {
  85. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  86. },
  87. {
  88. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  89. },
  90. {
  91. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  92. },
  93. {
  94. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  95. },
  96. ]
  97. # Internationalization
  98. # https://docs.djangoproject.com/en/3.0/topics/i18n/
  99. LANGUAGE_CODE = 'en-us'
  100. TIME_ZONE = 'UTC'
  101. USE_I18N = True
  102. USE_L10N = True
  103. USE_TZ = True
  104. # Static files (CSS, JavaScript, Images)
  105. # https://docs.djangoproject.com/en/3.0/howto/static-files/
  106. STATIC_URL = '/static/'
  107. REST_FRAMEWORK = {
  108. 'DEFAULT_AUTHENTICATION_CLASSES': (
  109. # 'rest_framework.authentication.BasicAuthentication',
  110. 'rest_framework.authentication.SessionAuthentication',
  111. 'django.contrib.auth.backends.ModelBackend',
  112. ),
  113. # PageNumberPagination 使用page传参分页
  114. 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
  115. 'PAGE_SIZE': 5,
  116. 'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'],
  117. 'DEFAULT_PERMISSION_CLASSES': [
  118. 'rest_framework.permissions.IsAuthenticated',
  119. ]
  120. }
  121. AUTHENTICATION_BACKENDS = [
  122. 'django.contrib.auth.backends.ModelBackend'
  123. ]