settings.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. """
  2. Django settings for core project.
  3. Generated by 'django-admin startproject' using Django 4.1.5.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/4.1/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/4.1/ref/settings/
  8. """
  9. from pathlib import Path
  10. import core.config_template as conf
  11. import os
  12. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  13. BASE_DIR = Path(__file__).resolve().parent.parent
  14. # Quick-start development settings - unsuitable for production
  15. # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
  16. # SECURITY WARNING: keep the secret key used in production secret!
  17. SECRET_KEY = conf.SECRET_KEY
  18. # SECURITY WARNING: don't run with debug turned on in production!
  19. DEBUG = conf.DEBUG
  20. ALLOWED_HOSTS = conf.ALLOWED_HOSTS
  21. CSRF_TRUSTED_ORIGINS = conf.CSRF_TRUSTED_ORIGINS
  22. # Application definition
  23. INSTALLED_APPS = [
  24. 'django.contrib.admin',
  25. 'django.contrib.auth',
  26. 'django.contrib.contenttypes',
  27. 'django.contrib.sessions',
  28. 'django.contrib.messages',
  29. 'django.contrib.staticfiles',
  30. 'butler.apps.ButlerConfig',
  31. 'ckeditor',
  32. #antispam
  33. 'captcha',
  34. ]
  35. MIDDLEWARE = [
  36. 'django.middleware.security.SecurityMiddleware',
  37. 'django.contrib.sessions.middleware.SessionMiddleware',
  38. 'django.middleware.common.CommonMiddleware',
  39. 'django.middleware.csrf.CsrfViewMiddleware',
  40. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  41. 'django.contrib.messages.middleware.MessageMiddleware',
  42. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  43. ]
  44. ROOT_URLCONF = 'core.urls'
  45. TEMPLATES = [
  46. {
  47. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  48. 'DIRS': [],
  49. 'APP_DIRS': True,
  50. 'OPTIONS': {
  51. 'context_processors': [
  52. 'django.template.context_processors.debug',
  53. 'django.template.context_processors.request',
  54. 'django.contrib.auth.context_processors.auth',
  55. 'django.contrib.messages.context_processors.messages',
  56. ],
  57. },
  58. },
  59. ]
  60. WSGI_APPLICATION = 'core.wsgi.application'
  61. # Database
  62. # https://docs.djangoproject.com/en/4.1/ref/settings/#databases
  63. if conf.DB_NAME is None:
  64. DATABASES = {
  65. 'default': {
  66. 'ENGINE': 'django.db.backends.sqlite3',
  67. 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
  68. }
  69. }
  70. else:
  71. DATABASES = {
  72. 'default': {
  73. 'ENGINE': 'django.db.backends.postgresql',
  74. 'NAME': conf.DB_NAME,
  75. 'USER': conf.DB_USER,
  76. 'PASSWORD': conf.DB_PASSWORD,
  77. 'HOST': conf.DB_HOST,
  78. 'PORT': '5432',
  79. }
  80. }
  81. # Password validation
  82. # https://docs.djangoproject.com/en/4.1/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/4.1/topics/i18n/
  99. LANGUAGE_CODE = 'ru'
  100. TIME_ZONE = 'UTC'
  101. USE_I18N = True
  102. USE_TZ = True
  103. # Static files (CSS, JavaScript, Images)
  104. # https://docs.djangoproject.com/en/4.1/howto/static-files/
  105. STATIC_URL = '/static/'
  106. STATICFILES_DIRS = [os.path.join(BASE_DIR, "butler/static")]
  107. STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
  108. MEDIA_ROOT = os.path.join(BASE_DIR, "media")
  109. MEDIA_URL = "/media/"
  110. #CKEDITOR_BASEPATH = "/staticfiles/ckeditor/ckeditor/"
  111. CKEDITOR_CONFIGS = {
  112. 'default': {
  113. 'toolbar': 'full',
  114. },
  115. }
  116. # Default primary key field type
  117. # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
  118. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  119. #SITE_ID = 1