settings.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. """
  2. Django settings for mserv00 project.
  3. Generated by 'django-admin startproject' using Django 5.2.3.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/5.2/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/5.2/ref/settings/
  8. """
  9. import os
  10. from pathlib import Path
  11. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  12. BASE_DIR = Path(__file__).resolve().parent.parent
  13. # Quick-start development settings - unsuitable for production
  14. # See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
  15. # SECURITY WARNING: keep the secret key used in production secret!
  16. SECRET_KEY = 'django-insecure-89&_=swo6&=@z714%#k6oo$ayu-cn5yu9k@h$+bq^=kf$#f!c3'
  17. # SECURITY WARNING: don't run with debug turned on in production!
  18. DEBUG = True
  19. ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
  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. 'rest_framework',
  29. 'django_filters',
  30. 'spectrometer'
  31. ]
  32. MIDDLEWARE = [
  33. 'django.middleware.security.SecurityMiddleware',
  34. 'django.contrib.sessions.middleware.SessionMiddleware',
  35. 'django.middleware.common.CommonMiddleware',
  36. 'django.middleware.csrf.CsrfViewMiddleware',
  37. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  38. 'django.contrib.messages.middleware.MessageMiddleware',
  39. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  40. ]
  41. ROOT_URLCONF = 'mserv00.urls'
  42. TEMPLATES = [
  43. {
  44. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  45. 'DIRS': [],
  46. 'APP_DIRS': True,
  47. 'OPTIONS': {
  48. 'context_processors': [
  49. 'django.template.context_processors.request',
  50. 'django.contrib.auth.context_processors.auth',
  51. 'django.contrib.messages.context_processors.messages',
  52. ],
  53. },
  54. },
  55. ]
  56. WSGI_APPLICATION = 'mserv00.wsgi.application'
  57. # Database
  58. # https://docs.djangoproject.com/en/5.2/ref/settings/#databases
  59. if os.getenv('USE_POSTGRES', '').lower() in {'1', 'true', 'yes'}:
  60. DATABASES = {
  61. 'default': {
  62. 'ENGINE': 'django.db.backends.postgresql',
  63. 'NAME': os.getenv('POSTGRES_DB', 'specdata'),
  64. 'USER': os.getenv('POSTGRES_USER', 'specadmin'),
  65. 'PASSWORD': os.getenv('POSTGRES_PASSWORD', 'specadmin'),
  66. 'HOST': os.getenv('POSTGRES_HOST', 'localhost'),
  67. 'PORT': os.getenv('POSTGRES_PORT', '5432'),
  68. }
  69. }
  70. else:
  71. DATABASES = {
  72. 'default': {
  73. 'ENGINE': 'django.db.backends.sqlite3',
  74. 'NAME': BASE_DIR / 'db.sqlite3',
  75. }
  76. }
  77. # Password validation
  78. # https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
  79. AUTH_PASSWORD_VALIDATORS = [
  80. {
  81. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  82. },
  83. {
  84. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  85. },
  86. {
  87. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  88. },
  89. {
  90. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  91. },
  92. ]
  93. REST_FRAMEWORK = {
  94. 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
  95. 'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'],
  96. 'PAGE_SIZE': 10
  97. }
  98. # Internationalization
  99. # https://docs.djangoproject.com/en/5.2/topics/i18n/
  100. LANGUAGE_CODE = 'ru-ru'
  101. TIME_ZONE = 'Europe/Moscow'
  102. USE_I18N = True
  103. USE_TZ = True
  104. # Static files (CSS, JavaScript, Images)
  105. # https://docs.djangoproject.com/en/5.2/howto/static-files/
  106. STATIC_URL = 'static/'
  107. STATIC_ROOT = BASE_DIR / 'static'
  108. # Default primary key field type
  109. # https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
  110. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'