|
10 | 10 | https://docs.djangoproject.com/en/3.2/ref/settings/
|
11 | 11 | """
|
12 | 12 |
|
13 |
| -import os |
| 13 | +import os, environ |
14 | 14 | from pathlib import Path
|
15 | 15 |
|
| 16 | +env = environ.Env( |
| 17 | + # set casting, default value |
| 18 | + DEBUG=(bool, False) |
| 19 | +) |
| 20 | + |
16 | 21 | # Build paths inside the project like this: BASE_DIR / 'subdir'.
|
17 | 22 | BASE_DIR = Path(__file__).resolve().parent.parent
|
18 | 23 |
|
19 | 24 | # Quick-start development settings - unsuitable for production
|
20 | 25 | # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
|
21 | 26 |
|
22 | 27 | # SECURITY WARNING: keep the secret key used in production secret!
|
23 |
| -SECRET_KEY = os.getenv( |
24 |
| - "SECRET_KEY", "django-insecure-97s)x3c8w8h_qv3t3s7%)#k@dpk2edr0ed_(rq9y(rbb&_!ai%" |
25 |
| -) |
| 28 | +SECRET_KEY = env('SECRET_KEY', default='insecure-S#perS3crEt_007') |
26 | 29 |
|
27 | 30 | # SECURITY WARNING: don't run with debug turned on in production!
|
28 |
| -DEBUG = int(os.environ.get("DEBUG", default=1)) |
| 31 | +DEBUG = int(env("DEBUG", default=0)) |
29 | 32 |
|
30 |
| -ALLOWED_HOSTS = os.getenv("DJANGO_ALLOWED_HOSTS", "*").split(" ") |
| 33 | +ALLOWED_HOSTS = env("DJANGO_ALLOWED_HOSTS", default="*").split(" ") |
31 | 34 |
|
32 | 35 | # Application definition
|
33 | 36 |
|
|
81 | 84 |
|
82 | 85 | DATABASES = {
|
83 | 86 | "default": {
|
84 |
| - "ENGINE": os.environ.get("DB_ENGINE", "django.db.backends.sqlite3"), |
85 |
| - "NAME": os.environ.get("DB_DATABASE", os.path.join(BASE_DIR, "db.sqlite3")), |
86 |
| - "USER": os.environ.get("DB_USER"), |
87 |
| - "PASSWORD": os.environ.get("DB_PASSWORD"), |
88 |
| - "HOST": os.environ.get("DB_HOST"), |
89 |
| - "PORT": os.environ.get("DB_PORT"), |
| 87 | + "ENGINE" : env("DB_ENGINE" , default="django.db.backends.sqlite3"), |
| 88 | + "NAME" : env("DB_DATABASE", default=os.path.join(BASE_DIR, "db.sqlite3")), |
| 89 | + "USER" : env("DB_USER" , default=None), |
| 90 | + "PASSWORD": env("DB_PASSWORD", default=None), |
| 91 | + "HOST" : env("DB_HOST" , default=None), |
| 92 | + "PORT" : env("DB_PORT" , default=None), |
90 | 93 | }
|
91 | 94 | }
|
92 | 95 |
|
|
131 | 134 |
|
132 | 135 | DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
133 | 136 |
|
| 137 | +# Custom user Model |
134 | 138 | AUTH_USER_MODEL = "api_user.User"
|
135 | 139 |
|
136 | 140 | # ##################################################################### #
|
|
148 | 152 | # ################### CORS ############################### #
|
149 | 153 | # ##################################################################### #
|
150 | 154 |
|
| 155 | +# Load the default ones |
151 | 156 | CORS_ALLOWED_ORIGINS = ["http://localhost:3000", "http://127.0.0.1:3000"]
|
152 | 157 |
|
| 158 | +# Leaded from Environment |
| 159 | +CORS_ALLOWED_ORIGINS_ENV = env("CORS_ALLOWED_ORIGINS", default=None) |
| 160 | + |
| 161 | +if CORS_ALLOWED_ORIGINS_ENV: |
| 162 | + CORS_ALLOWED_ORIGINS += CORS_ALLOWED_ORIGINS_ENV.split(' ') |
| 163 | + |
153 | 164 | # ##################################################################### #
|
154 | 165 | # ################### TESTING ############################### #
|
155 | 166 | # ##################################################################### #
|
|
0 commit comments