Use python-decouple for managing environment variables
This commit is contained in:
parent
58f7364688
commit
e0c122016a
@ -12,10 +12,7 @@ https://docs.djangoproject.com/en/2.2/ref/settings/
|
||||
|
||||
import os
|
||||
import posixpath
|
||||
import environ
|
||||
|
||||
# Environment variables
|
||||
env = environ.Env()
|
||||
from decouple import config
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
@ -120,11 +117,11 @@ ASGI_APPLICATION = "config.asgi.application"
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.postgresql_psycopg2",
|
||||
"NAME": env("DB_NAME"),
|
||||
"USER": env("DB_USER"),
|
||||
"PASSWORD": env("DB_PASSWORD"),
|
||||
"HOST": env("DB_HOST"),
|
||||
"PORT": env("DB_PORT"),
|
||||
"NAME": config("DB_NAME"),
|
||||
"USER": config("DB_USER"),
|
||||
"PASSWORD": config("DB_PASSWORD"),
|
||||
"HOST": config("DB_HOST", default="localhost"),
|
||||
"PORT": config("DB_PORT", default=5432),
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,7 +168,7 @@ STATIC_URL = "/static/"
|
||||
STATICFILES_DIRS = [
|
||||
os.path.join(BASE_DIR, "static"),
|
||||
]
|
||||
STATIC_ROOT = posixpath.join(*(BASE_DIR.split(os.path.sep) + ["staticfiles"]))
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
|
||||
|
||||
MEDIA_URL = "/media/"
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
||||
@ -180,13 +177,11 @@ MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
||||
# E-mail configuration
|
||||
|
||||
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
|
||||
EMAIL_HOST = (
|
||||
"smtp.gmail.com" # Here i'm using gmail as the email host, but you can change it
|
||||
)
|
||||
EMAIL_PORT = 587
|
||||
EMAIL_HOST = "smtp.gmail.com" # Gmail as the email host, but you can change it
|
||||
EMAIL_PORT = config("EMAIL_PORT", default=587)
|
||||
EMAIL_USE_TLS = True
|
||||
EMAIL_HOST_USER = env("USER_EMAIL")
|
||||
EMAIL_HOST_PASSWORD = env("USER_PASSWORD")
|
||||
EMAIL_HOST_USER = config("USER_EMAIL")
|
||||
EMAIL_HOST_PASSWORD = config("USER_PASSWORD")
|
||||
|
||||
# crispy config
|
||||
CRISPY_TEMPLATE_PACK = "bootstrap4"
|
||||
@ -206,5 +201,5 @@ REST_FRAMEWORK = {
|
||||
}
|
||||
|
||||
# Strip payment config
|
||||
STRIPE_SECRET_KEY = env("STRIPE_SECRET_KEY")
|
||||
STRIPE_PUBLISHABLE_KEY = env("STRIPE_PUBLISHABLE_KEY")
|
||||
STRIPE_SECRET_KEY = config("STRIPE_SECRET_KEY", default="")
|
||||
STRIPE_PUBLISHABLE_KEY = config("STRIPE_PUBLISHABLE_KEY", default="")
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
"""Django's command-line utility for administrative tasks."""
|
||||
import os
|
||||
import sys
|
||||
import environ
|
||||
|
||||
|
||||
def main():
|
||||
@ -19,6 +18,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# OS environment variables take precedence over variables from .env
|
||||
environ.Env.read_env()
|
||||
main()
|
||||
|
||||
@ -10,7 +10,6 @@ hiredis==2.1.0 # https://github.com/redis/hiredis-py
|
||||
# Django
|
||||
# ------------------------------------------------------------------------------
|
||||
django==4.0.8 # pyup: < 4.1 # https://www.djangoproject.com/
|
||||
django-environ==0.9.0 # https://github.com/joke2k/django-environ
|
||||
django-model-utils==4.3.1 # https://github.com/jazzband/django-model-utils
|
||||
django-crispy-forms==1.14.0 # https://github.com/django-crispy-forms/django-crispy-forms
|
||||
crispy-bootstrap5==0.7 # https://github.com/django-crispy-forms/crispy-bootstrap5
|
||||
@ -27,4 +26,7 @@ stripe==5.5.0
|
||||
gopay==2.0.1
|
||||
|
||||
# Customize django admin
|
||||
django-jet-reboot==1.3.5
|
||||
django-jet-reboot==1.3.5
|
||||
|
||||
# Environment variable
|
||||
python-decouple==3.8
|
||||
Loading…
x
Reference in New Issue
Block a user