| 1 | import os.path
|
|---|
| 2 | from pathlib import Path
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 | import environ
|
|---|
| 6 | from decimal import getcontext, ROUND_HALF_UP
|
|---|
| 7 |
|
|---|
| 8 | BASE_DIR = Path(__file__).resolve().parent.parent
|
|---|
| 9 | env_file = os.path.join(BASE_DIR, ".env.production")
|
|---|
| 10 | if not os.path.isfile(env_file):
|
|---|
| 11 | env_file = os.path.join(BASE_DIR, ".env.development")
|
|---|
| 12 | if not os.path.isfile(env_file):
|
|---|
| 13 | env_file = os.path.join(BASE_DIR, ".env")
|
|---|
| 14 |
|
|---|
| 15 | environ.Env.read_env(os.path.join(BASE_DIR, env_file))
|
|---|
| 16 |
|
|---|
| 17 | getcontext().rounding = ROUND_HALF_UP
|
|---|
| 18 |
|
|---|
| 19 | env = environ.Env(
|
|---|
| 20 | DEBUG=(bool, False)
|
|---|
| 21 | )
|
|---|
| 22 |
|
|---|
| 23 | DEBUG = bool(env("DJANGO_DEBUG"))
|
|---|
| 24 |
|
|---|
| 25 | SECRET_KEY = env("DJANGO_SECRET_KEY")
|
|---|
| 26 |
|
|---|
| 27 | ALLOWED_HOSTS = [
|
|---|
| 28 | ".localhost",
|
|---|
| 29 | "127.0.0.1",
|
|---|
| 30 | "[::1]",
|
|---|
| 31 | ]
|
|---|
| 32 |
|
|---|
| 33 | INTERNAL_IPS = [
|
|---|
| 34 | "127.0.0.1",
|
|---|
| 35 | ]
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | # Application definition
|
|---|
| 39 | INSTALLED_APPS = [
|
|---|
| 40 | "daphne",
|
|---|
| 41 | "django.contrib.admin",
|
|---|
| 42 | "django.contrib.auth",
|
|---|
| 43 | "django.contrib.contenttypes",
|
|---|
| 44 | "django.contrib.sessions",
|
|---|
| 45 | "django.contrib.messages",
|
|---|
| 46 | "django.contrib.staticfiles",
|
|---|
| 47 | "django_filters",
|
|---|
| 48 | "rest_framework",
|
|---|
| 49 | "corsheaders",
|
|---|
| 50 | "directories",
|
|---|
| 51 | ]
|
|---|
| 52 |
|
|---|
| 53 | MIDDLEWARE = [
|
|---|
| 54 | "django.middleware.security.SecurityMiddleware",
|
|---|
| 55 | "django.contrib.sessions.middleware.SessionMiddleware",
|
|---|
| 56 | "corsheaders.middleware.CorsMiddleware",
|
|---|
| 57 | "django.middleware.common.CommonMiddleware",
|
|---|
| 58 | "django.middleware.csrf.CsrfViewMiddleware",
|
|---|
| 59 | "django.contrib.auth.middleware.AuthenticationMiddleware",
|
|---|
| 60 | "django.contrib.messages.middleware.MessageMiddleware",
|
|---|
| 61 | "django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|---|
| 62 | ]
|
|---|
| 63 |
|
|---|
| 64 | ROOT_URLCONF = "backend.urls"
|
|---|
| 65 |
|
|---|
| 66 | TEMPLATES = [
|
|---|
| 67 | {
|
|---|
| 68 | "BACKEND": "django.template.backends.django.DjangoTemplates",
|
|---|
| 69 | "DIRS": [BASE_DIR / "templates"],
|
|---|
| 70 | "APP_DIRS": True,
|
|---|
| 71 | "OPTIONS": {
|
|---|
| 72 | "context_processors": [
|
|---|
| 73 | "django.template.context_processors.debug",
|
|---|
| 74 | "django.template.context_processors.request",
|
|---|
| 75 | "django.contrib.auth.context_processors.auth",
|
|---|
| 76 | "django.contrib.messages.context_processors.messages",
|
|---|
| 77 | ],
|
|---|
| 78 | },
|
|---|
| 79 | },
|
|---|
| 80 | ]
|
|---|
| 81 |
|
|---|
| 82 | WSGI_APPLICATION = "backend.wsgi.application"
|
|---|
| 83 | ASGI_APPLICATION = "backend.asgi.application"
|
|---|
| 84 |
|
|---|
| 85 | STATIC_URL = "staticfiles/"
|
|---|
| 86 | STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
|
|---|
| 87 |
|
|---|
| 88 | # Database
|
|---|
| 89 | DATABASES = {
|
|---|
| 90 | "default": {
|
|---|
| 91 | "ENGINE": "django.db.backends.postgresql",
|
|---|
| 92 | "NAME": env("DATABASE_NAME"),
|
|---|
| 93 | "USER": env("DATABASE_USER"),
|
|---|
| 94 | "PASSWORD": env("DATABASE_PASSWORD"),
|
|---|
| 95 | "HOST": env("DATABASE_HOST"),
|
|---|
| 96 | "PORT": env("DATABASE_PORT"),
|
|---|
| 97 | }
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | # Default primary key field type
|
|---|
| 101 | DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|---|
| 102 |
|
|---|
| 103 | REST_FRAMEWORK = {
|
|---|
| 104 | "DEFAULT_METADATA_CLASS": [
|
|---|
| 105 | "rest_framework.renderers.JSONRenderer",
|
|---|
| 106 | "rest_framework.metadata.SimpleMetadata",
|
|---|
| 107 | ],
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | CORS_ORIGIN_ALLOW_ALL = True
|
|---|