diff --git a/.env-example b/.env-example index eb671ba..ffb0591 100644 --- a/.env-example +++ b/.env-example @@ -16,15 +16,15 @@ DJANGO_SETTINGS_MODULE=core.settings.development # default PRIVATE_KEY_PATH=security_settings/private_key.pem PUBLIC_KEY_PATH=security_settings/public_key.pem -#### Django database environs sqlite, postgres #### -DATABASE_ENVIRON=sqlite +#### Django database environs sqlite3, postgres, mysql #### +DATABASE_ENVIRON=sqlite3 #### PostgreSQL configurations #### -POSTGRES_NAME=POSTGRES_NAME -POSTGRES_USER=POSTGRES_USER -POSTGRES_PASSWORD=POSTGRES_PASSWORD -POSTGRES_HOST=localhost -POSTGRES_PORT=5432 +DATABASE_NAME=POSTGRES_NAME +DATABASE_USER=POSTGRES_USER +DATABASE_PASSWORD=POSTGRES_PASSWORD +DATABASE_HOST=localhost +DATABASE_PORT=5432 #### Django Admin param #### diff --git a/README.md b/README.md index 45d8c35..d70540d 100644 --- a/README.md +++ b/README.md @@ -65,11 +65,11 @@ PUBLIC_KEY_PATH=security_settings/public_key.pem # default DATABASE_ENVIRON=sqlite # sqlite or postgres # PostgreSQL configruations -POSTGRES_NAME= -POSTGRES_USER= -POSTGRES_PASSWORD= -POSTGRES_HOST=localhost # default -POSTGRES_PORT=5432 # default +DATABASE_NAME= +DATABASE_USER= +DATABASE_PASSWORD= +DATABASE_HOST=localhost # default +DATABASE_PORT=5432 # default ADMIN_USERNAME=admin # default ADMIN_PASSWORD=password # default diff --git a/core/settings/base.py b/core/settings/base.py index 8deb537..b4bd78c 100644 --- a/core/settings/base.py +++ b/core/settings/base.py @@ -54,14 +54,6 @@ WSGI_APPLICATION = "core.wsgi.application" -DATABASES = { - "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": BASE_DIR / "db.sqlite3", - } -} - - AUTH_PASSWORD_VALIDATORS = [ { "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", diff --git a/core/settings/development.py b/core/settings/development.py index 4b995bb..b3e5109 100644 --- a/core/settings/development.py +++ b/core/settings/development.py @@ -1,3 +1,12 @@ +import os + from .base import * # noqa EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" + +DATABASES = { + "default": { + "ENGINE": f"django.db.backends.{str(os.getenv('DATABASE_ENVIRON'))}", + "NAME": BASE_DIR / "db.sqlite3", + } +} \ No newline at end of file diff --git a/core/settings/production.py b/core/settings/production.py index 61428b9..b3eb0c8 100644 --- a/core/settings/production.py +++ b/core/settings/production.py @@ -11,12 +11,12 @@ DATABASES = { "default": { - "ENGINE": "django.db.backends.postgresql", - "NAME": str(os.getenv("POSTGRES_NAME")), - "USER": str(os.getenv("POSTGRES_USER")), - "PASSWORD": str(os.getenv("POSTGRES_PASSWORD")), - "HOST": str(os.getenv("POSTGRES_HOST")), - "PORT": int(os.getenv("POSTGRES_PORT")) + "ENGINE": f"django.db.backends.{str(os.getenv('DATABASE_ENVIRON'))}", + "NAME": str(os.getenv("DATABASE_NAME")), + "USER": str(os.getenv("DATABASE_USER")), + "PASSWORD": str(os.getenv("DATABASE_PASSWORD")), + "HOST": str(os.getenv("DATABASE_HOST")), + "PORT": int(os.getenv("DATABASE_PORT")) } }