settings.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. """
  2. Django settings for board project.
  3. Generated by 'django-admin startproject' using Django 4.1.4.
  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. # Build paths inside the project like this: BASE_DIR / 'subdir'.
  11. BASE_DIR = Path(__file__).resolve().parent.parent
  12. # Quick-start development settings - unsuitable for production
  13. # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
  14. # SECURITY WARNING: keep the secret key used in production secret!
  15. SECRET_KEY = 'django-insecure-zqg+!d+16wwcyv$dv&vvox4d!*8jkazh0conc866uiw08cz(^g'
  16. # SECURITY WARNING: don't run with debug turned on in production!
  17. DEBUG = True
  18. ALLOWED_HOSTS = ['board.adminkin.com', '95.31.13.58', 'server2014.ru']
  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. 'main.apps.MainConfig',
  28. 'bootstrap4',
  29. 'django_cleanup',
  30. 'easy_thumbnails',
  31. 'captcha',
  32. 'rest_framework',
  33. 'corsheaders',
  34. 'api.apps.ApiConfig',
  35. ]
  36. MIDDLEWARE = [
  37. 'django.middleware.security.SecurityMiddleware',
  38. 'django.contrib.sessions.middleware.SessionMiddleware',
  39. 'corsheaders.middleware.CorsMiddleware',
  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 = 'board.urls'
  47. TEMPLATES = [
  48. {
  49. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  50. 'DIRS': [],
  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. 'main.middlewares.board_context_processor',
  59. ],
  60. },
  61. },
  62. ]
  63. WSGI_APPLICATION = 'board.wsgi.application'
  64. # Database
  65. # https://docs.djangoproject.com/en/4.1/ref/settings/#databases
  66. DATABASES = {
  67. 'default': {
  68. 'ENGINE': 'django.db.backends.sqlite3',
  69. 'NAME': BASE_DIR / 'board.db.sqlite3',
  70. }
  71. }
  72. # Password validation
  73. # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
  74. AUTH_PASSWORD_VALIDATORS = [
  75. {
  76. 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  77. },
  78. {
  79. 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  80. },
  81. {
  82. 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  83. },
  84. {
  85. 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  86. },
  87. ]
  88. AUTH_USER_MODEL = 'main.AdvUser'
  89. # Internationalization
  90. # https://docs.djangoproject.com/en/4.1/topics/i18n/
  91. LANGUAGE_CODE = 'ru'
  92. TIME_ZONE = 'Europe/Moscow'
  93. USE_I18N = True
  94. USE_TZ = True
  95. # Static files (CSS, JavaScript, Images)
  96. # https://docs.djangoproject.com/en/4.1/howto/static-files/
  97. import os
  98. STATIC_URL = 'static/'
  99. STATIC_ROOT = os.path.join(BASE_DIR, 'static')
  100. MEDIA_URL = 'media/'
  101. MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
  102. THUMBNAIL_ALIASES = {
  103. '': {
  104. 'default': {
  105. 'size': (96, 96),
  106. 'crop': 'scale',
  107. },
  108. },
  109. }
  110. THUMBNAIL_BASEDIR = 'thumbnails' # Имя вложенной папки для хранения миниатюр
  111. # Default primary key field type
  112. # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
  113. DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  114. DEFAULT_FROM_EMAIL = 'no-reply@server2014.ru'
  115. EMAIL_HOST = 'localhost'
  116. EMAIL_PORT = 25
  117. # Разрешаем доступ к веб-службе с любого домена
  118. CORS_ORIGIN_ALLOW_ALL = True
  119. CORS_URLS_REGEX = r'^/api/.*$'