|  |  |  | @ -12,21 +12,165 @@ https://docs.djangoproject.com/en/4.0/ref/settings/ | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | from pathlib import Path | 
			
		
	
		
			
				
					|  |  |  |  | import os | 
			
		
	
		
			
				
					|  |  |  |  | import environ | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # Build paths inside the project like this: BASE_DIR / 'subdir'. | 
			
		
	
		
			
				
					|  |  |  |  | BASE_DIR = Path(__file__).resolve().parent.parent | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | environ.Env.read_env(os.path.join(BASE_DIR, ".env")) | 
			
		
	
		
			
				
					|  |  |  |  | env = environ.Env( | 
			
		
	
		
			
				
					|  |  |  |  |     # set casting, default value | 
			
		
	
		
			
				
					|  |  |  |  |     DEBUG=(bool, False), | 
			
		
	
		
			
				
					|  |  |  |  |     DEVELOPMENT_MODE=(bool, False), | 
			
		
	
		
			
				
					|  |  |  |  | ) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # Build paths inside the project like this: BASE_DIR / 'subdir'. | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | PROJECT_ROOT = os.path.dirname(__file__) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # Quick-start development settings - unsuitable for production | 
			
		
	
		
			
				
					|  |  |  |  | # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # SECURITY WARNING: keep the secret key used in production secret! | 
			
		
	
		
			
				
					|  |  |  |  | SECRET_KEY = env("SECRET_KEY") | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # SECURITY WARNING: don't run with debug turned on in production! | 
			
		
	
		
			
				
					|  |  |  |  | DEBUG = env("DEBUG") | 
			
		
	
		
			
				
					|  |  |  |  | DEVELOPMENT_MODE = env("DEVELOPMENT_MODE") | 
			
		
	
		
			
				
					|  |  |  |  | ALLOWED_HOSTS = ["127.0.0.1"] | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # Application definition | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | INSTALLED_APPS = [ | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.admin", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.auth", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.contenttypes", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.sessions", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.messages", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.staticfiles", | 
			
		
	
		
			
				
					|  |  |  |  |     "posts.apps.PostConfig", | 
			
		
	
		
			
				
					|  |  |  |  |     "mainpage.apps.MainpageConfig", | 
			
		
	
		
			
				
					|  |  |  |  |     "comments.apps.CommentsConfig", | 
			
		
	
		
			
				
					|  |  |  |  | ] | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | MIDDLEWARE = [ | 
			
		
	
		
			
				
					|  |  |  |  |     "django.middleware.security.SecurityMiddleware", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.sessions.middleware.SessionMiddleware", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.middleware.common.CommonMiddleware", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.middleware.csrf.CsrfViewMiddleware", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.auth.middleware.AuthenticationMiddleware", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.messages.middleware.MessageMiddleware", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.middleware.clickjacking.XFrameOptionsMiddleware", | 
			
		
	
		
			
				
					|  |  |  |  | ] | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | ROOT_URLCONF = "blog.urls" | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | TEMPLATES = [ | 
			
		
	
		
			
				
					|  |  |  |  |     { | 
			
		
	
		
			
				
					|  |  |  |  |         "BACKEND": "django.template.backends.django.DjangoTemplates", | 
			
		
	
		
			
				
					|  |  |  |  |         "DIRS": [os.path.join(BASE_DIR, "templates")], | 
			
		
	
		
			
				
					|  |  |  |  |         "APP_DIRS": True, | 
			
		
	
		
			
				
					|  |  |  |  |         "OPTIONS": { | 
			
		
	
		
			
				
					|  |  |  |  |             "context_processors": [ | 
			
		
	
		
			
				
					|  |  |  |  |                 "django.template.context_processors.debug", | 
			
		
	
		
			
				
					|  |  |  |  |                 "django.template.context_processors.request", | 
			
		
	
		
			
				
					|  |  |  |  |                 "django.contrib.auth.context_processors.auth", | 
			
		
	
		
			
				
					|  |  |  |  |                 "django.contrib.messages.context_processors.messages", | 
			
		
	
		
			
				
					|  |  |  |  |             ], | 
			
		
	
		
			
				
					|  |  |  |  |         }, | 
			
		
	
		
			
				
					|  |  |  |  |     }, | 
			
		
	
		
			
				
					|  |  |  |  | ] | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | WSGI_APPLICATION = "blog.wsgi.application" | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # Database | 
			
		
	
		
			
				
					|  |  |  |  | # https://docs.djangoproject.com/en/4.0/ref/settings/#databases | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | if DEVELOPMENT_MODE=(bool, False), | 
			
		
	
		
			
				
					|  |  |  |  | ) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # Build paths inside the project like this: BASE_DIR / 'subdir'. | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | PROJECT_ROOT = os.path.dirname(__file__) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # Quick-start development settings - unsuitable for production | 
			
		
	
		
			
				
					|  |  |  |  | # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # SECURITY WARNING: keep the secret key used in production secret! | 
			
		
	
		
			
				
					|  |  |  |  | SECRET_KEY = "django-insecure-+-=x#$t4ympabt6#3#k=5t2w60%uiz7l6une62r+i6@sw9jds(" | 
			
		
	
		
			
				
					|  |  |  |  | SECRET_KEY = env("SECRET_KEY") | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # SECURITY WARNING: don't run with debug turned on in production! | 
			
		
	
		
			
				
					|  |  |  |  | DEBUG = True | 
			
		
	
		
			
				
					|  |  |  |  | DEBUG = env("DEBUG") | 
			
		
	
		
			
				
					|  |  |  |  | DEVELOPMENT_MODE = env("DEVELOPMENT_MODE") | 
			
		
	
		
			
				
					|  |  |  |  | ALLOWED_HOSTS = ["127.0.0.1"] | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # Application definition | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | INSTALLED_APPS = [ | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.admin", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.auth", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.contenttypes", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.sessions", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.messages", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.staticfiles", | 
			
		
	
		
			
				
					|  |  |  |  |     "posts.apps.PostConfig", | 
			
		
	
		
			
				
					|  |  |  |  |     "mainpage.apps.MainpageConfig", | 
			
		
	
		
			
				
					|  |  |  |  |     "comments.apps.CommentsConfig", | 
			
		
	
		
			
				
					|  |  |  |  | ] | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | MIDDLEWARE = [ | 
			
		
	
		
			
				
					|  |  |  |  |     "django.middleware.security.SecurityMiddleware", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.sessions.middleware.SessionMiddleware", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.middleware.common.CommonMiddleware", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.middleware.csrf.CsrfViewMiddleware", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.auth.middleware.AuthenticationMiddleware", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.contrib.messages.middleware.MessageMiddleware", | 
			
		
	
		
			
				
					|  |  |  |  |     "django.middleware.clickjacking.XFrameOptionsMiddleware", | 
			
		
	
		
			
				
					|  |  |  |  | ] | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | ROOT_URLCONF = "blog.urls" | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | TEMPLATES = [ | 
			
		
	
		
			
				
					|  |  |  |  |     { | 
			
		
	
		
			
				
					|  |  |  |  |         "BACKEND": "django.template.backends.django.DjangoTemplates", | 
			
		
	
		
			
				
					|  |  |  |  |         "DIRS": [os.path.join(BASE_DIR, "templates")], | 
			
		
	
		
			
				
					|  |  |  |  |         "APP_DIRS": True, | 
			
		
	
		
			
				
					|  |  |  |  |         "OPTIONS": { | 
			
		
	
		
			
				
					|  |  |  |  |             "context_processors": [ | 
			
		
	
		
			
				
					|  |  |  |  |                 "django.template.context_processors.debug", | 
			
		
	
		
			
				
					|  |  |  |  |                 "django.template.context_processors.request", | 
			
		
	
		
			
				
					|  |  |  |  |                 "django.contrib.auth.context_processors.auth", | 
			
		
	
		
			
				
					|  |  |  |  |                 "django.contrib.messages.context_processors.messages", | 
			
		
	
		
			
				
					|  |  |  |  |             ], | 
			
		
	
		
			
				
					|  |  |  |  |         }, | 
			
		
	
		
			
				
					|  |  |  |  |     }, | 
			
		
	
		
			
				
					|  |  |  |  | ] | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | WSGI_APPLICATION = "blog.wsgi.application" | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | ALLOWED_HOSTS = [] | 
			
		
	
		
			
				
					|  |  |  |  | # Database | 
			
		
	
		
			
				
					|  |  |  |  | # https://docs.djangoproject.com/en/4.0/ref/settings/#databases | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | if DEVELOPMENT_MODE=(bool, False), | 
			
		
	
		
			
				
					|  |  |  |  | ) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # Build paths inside the project like this: BASE_DIR / 'subdir'. | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | PROJECT_ROOT = os.path.dirname(__file__) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # Quick-start development settings - unsuitable for production | 
			
		
	
		
			
				
					|  |  |  |  | # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # SECURITY WARNING: keep the secret key used in production secret! | 
			
		
	
		
			
				
					|  |  |  |  | SECRET_KEY = env("SECRET_KEY") | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # SECURITY WARNING: don't run with debug turned on in production! | 
			
		
	
		
			
				
					|  |  |  |  | DEBUG = env("DEBUG") | 
			
		
	
		
			
				
					|  |  |  |  | DEVELOPMENT_MODE = env("DEVELOPMENT_MODE") | 
			
		
	
		
			
				
					|  |  |  |  | ALLOWED_HOSTS = ["127.0.0.1"] | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # Application definition | 
			
		
	
	
		
			
				
					|  |  |  | @ -77,10 +221,20 @@ WSGI_APPLICATION = "blog.wsgi.application" | 
			
		
	
		
			
				
					|  |  |  |  | # Database | 
			
		
	
		
			
				
					|  |  |  |  | # https://docs.djangoproject.com/en/4.0/ref/settings/#databases | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | DATABASES = { | 
			
		
	
		
			
				
					|  |  |  |  | if DEVELOPMENT_MODE: | 
			
		
	
		
			
				
					|  |  |  |  |     DATABASES = { | 
			
		
	
		
			
				
					|  |  |  |  |         "default": { | 
			
		
	
		
			
				
					|  |  |  |  |             "ENGINE": "django.db.backends.sqlite3", | 
			
		
	
		
			
				
					|  |  |  |  |             "NAME": os.path.join(BASE_DIR, "db.sqlite3"), | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | else: | 
			
		
	
		
			
				
					|  |  |  |  |     DATABASES = { | 
			
		
	
		
			
				
					|  |  |  |  |     "default": { | 
			
		
	
		
			
				
					|  |  |  |  |         "ENGINE": "django.db.backends.sqlite3", | 
			
		
	
		
			
				
					|  |  |  |  |         "NAME": BASE_DIR / "db.sqlite3", | 
			
		
	
		
			
				
					|  |  |  |  |         "ENGINE": "django.db.backends.postgresql", | 
			
		
	
		
			
				
					|  |  |  |  |         "OPTIONS": { | 
			
		
	
		
			
				
					|  |  |  |  |             "service": "django_test", | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -123,7 +277,7 @@ STATIC_URL = "static/" | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | # для того чтобы использовать общие статические файлы | 
			
		
	
		
			
				
					|  |  |  |  | STATICFILES_DIRS = [ | 
			
		
	
		
			
				
					|  |  |  |  |     BASE_DIR / "static", | 
			
		
	
		
			
				
					|  |  |  |  |     os.path.join(BASE_DIR, "static"), | 
			
		
	
		
			
				
					|  |  |  |  | ] | 
			
		
	
		
			
				
					|  |  |  |  | # Default primary key field type | 
			
		
	
		
			
				
					|  |  |  |  | # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field | 
			
		
	
	
		
			
				
					|  |  |  | 
 |