settings.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. """
  2. Django settings for my_project 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 = 'g9x!2%visyznwu#6a35)sygefkeu_z=oc5t8!hh%=jt)mw$cn('
  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. 'django_filters',
  29. 'workreport',
  30. 'mptt',
  31. 'workTtree',
  32. 'treeAndTable',
  33. 'payment',
  34. 'basic',
  35. 'rolepermissions',
  36. ]
  37. MIDDLEWARE = [
  38. 'django.middleware.security.SecurityMiddleware',
  39. 'django.contrib.sessions.middleware.SessionMiddleware',
  40. 'django.middleware.common.CommonMiddleware',
  41. 'django.middleware.csrf.CsrfViewMiddleware',
  42. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  43. 'django.contrib.messages.middleware.MessageMiddleware',
  44. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  45. ]
  46. ROOT_URLCONF = 'my_project.urls'
  47. TEMPLATES = [
  48. {
  49. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  50. 'DIRS': [os.path.join(BASE_DIR, 'templates')]
  51. ,
  52. 'APP_DIRS': True,
  53. 'OPTIONS': {
  54. 'context_processors': [
  55. 'django.template.context_processors.debug',
  56. 'django.template.context_processors.request',
  57. 'django.contrib.auth.context_processors.auth',
  58. 'django.contrib.messages.context_processors.messages',
  59. ],
  60. },
  61. },
  62. ]
  63. WSGI_APPLICATION = 'my_project.wsgi.application'
  64. # Database
  65. # https://docs.djangoproject.com/en/3.0/ref/settings/#databases
  66. DATABASES = {
  67. 'default': {
  68. 'ENGINE': 'django.db.backends.mysql',
  69. 'NAME': "linjj_django_demo",
  70. "USER": "root",
  71. "PASSWORD": "abc.123",
  72. "HOST": "srv.test.linkerplus.com",
  73. "PORT": "3310"
  74. }
  75. }
  76. # Password validation
  77. # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
  78. AUTH_PASSWORD_VALIDATORS = [
  79. {
  80. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  81. },
  82. {
  83. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  84. },
  85. {
  86. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  87. },
  88. {
  89. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  90. },
  91. ]
  92. # Internationalization
  93. # https://docs.djangoproject.com/en/3.0/topics/i18n/
  94. LANGUAGE_CODE = 'en-us'
  95. TIME_ZONE = 'UTC'
  96. USE_I18N = True
  97. USE_L10N = True
  98. USE_TZ = True
  99. # Static files (CSS, JavaScript, Images)
  100. # https://docs.djangoproject.com/en/3.0/howto/static-files/
  101. STATIC_URL = '/static/'
  102. REST_FRAMEWORK = {
  103. # 设置分页默认类 ?limit=?&offset=? 更习惯使用 PageNumberPagination
  104. 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
  105. 'PAGE_SIZE': 3,
  106. # 设置过滤默认类 SearchFilter搜索类、OrderingFilter排序类
  107. 'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'],
  108. 'DEFAULT_PERMISSION_CLASSES': ['rest_framework.permissions.IsAuthenticated'],
  109. 'DEFAULT_AUTHENTICATION_CLASSES': (
  110. 'rest_framework.authentication.BasicAuthentication',
  111. 'rest_framework.authentication.SessionAuthentication',
  112. )
  113. }
  114. AUTHENTICATION_BACKENDS = (
  115. 'django.contrib.auth.backends.ModelBackend'
  116. )
  117. ROLEPERMISSIONS_MODULE = 'my_project.roles'