133 lines
3.3 KiB
Python
133 lines
3.3 KiB
Python
import os
|
|
from pathlib import Path
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", "secret_key")
|
|
|
|
DEBUG = os.getenv("DJANGO_DEBUG", "true").lower() in ("true", "1", "yes", "y")
|
|
|
|
ALLOWED_HOSTS = os.getenv("DJANGO_ALLOWED_HOSTS", "*").split(" ")
|
|
|
|
INTERNAL_IPS = os.getenv("DJANGO_INTERNAL_IPS", "127.0.0.1").split(" ")
|
|
|
|
INSTALLED_APPS = [
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
# Third-party apps
|
|
"rest_framework",
|
|
"django_filters",
|
|
# Developed apps
|
|
"api.ping.apps.PingConfig",
|
|
"api.countries.apps.CountriesConfig",
|
|
"api.users.apps.UsersConfig",
|
|
"api.posts.apps.PostsConfig",
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
"django.middleware.security.SecurityMiddleware",
|
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
"django.middleware.common.CommonMiddleware",
|
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
"django.contrib.messages.middleware.MessageMiddleware",
|
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
]
|
|
|
|
ROOT_URLCONF = "pulse.urls"
|
|
|
|
TEMPLATES = [
|
|
{
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
"DIRS": [],
|
|
"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 = "pulse.wsgi.application"
|
|
|
|
DATABASES = {
|
|
"default": {
|
|
"ENGINE": "django.db.backends.postgresql",
|
|
"NAME": os.getenv("POSTGRES_DATABASE"),
|
|
"USER": os.getenv("POSTGRES_USERNAME"),
|
|
"PASSWORD": os.getenv("POSTGRES_PASSWORD"),
|
|
"HOST": os.getenv("POSTGRES_HOST"),
|
|
"PORT": os.getenv("POSTGRES_PORT"),
|
|
},
|
|
}
|
|
|
|
AUTH_PASSWORD_VALIDATORS = [
|
|
{
|
|
"NAME": (
|
|
"django.contrib.auth.password_validation."
|
|
"UserAttributeSimilarityValidator"
|
|
),
|
|
},
|
|
{
|
|
"NAME": (
|
|
"django.contrib.auth.password_validation.MinimumLengthValidator"
|
|
),
|
|
},
|
|
{
|
|
"NAME": (
|
|
"django.contrib.auth.password_validation.CommonPasswordValidator"
|
|
),
|
|
},
|
|
{
|
|
"NAME": (
|
|
"django.contrib.auth.password_validation.NumericPasswordValidator"
|
|
),
|
|
},
|
|
]
|
|
|
|
REGIONS = ["Europe", "Africa", "Americas", "Oceania", "Asia"]
|
|
|
|
LANGUAGE_CODE = "en-us"
|
|
|
|
TIME_ZONE = "UTC"
|
|
|
|
USE_I18N = True
|
|
|
|
USE_TZ = True
|
|
|
|
STATIC_URL = "static/"
|
|
|
|
STATIC_ROOT = BASE_DIR / "static"
|
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|
|
|
REST_FRAMEWORK = {
|
|
"DEFAULT_FILTER_BACKENDS": [
|
|
"django_filters.rest_framework.DjangoFilterBackend"
|
|
],
|
|
"DEFAULT_AUTHENTICATION_CLASSES": (
|
|
"api.users.authentication.JWTAuthentication",
|
|
),
|
|
"EXCEPTION_HANDLER": "pulse.utils.wrap_error_into_reason",
|
|
"DATETIME_FORMAT": "%Y-%m-%dT%H:%M:%SZ",
|
|
}
|
|
|
|
APPEND_SLASH = False
|
|
|
|
MAX_TAG_LENGTH = 20
|
|
|
|
if DEBUG:
|
|
INSTALLED_APPS.insert(0, "debug_toolbar")
|
|
MIDDLEWARE.append("debug_toolbar.middleware.DebugToolbarMiddleware")
|