From 9afa7f928f5017170cee6d44a623a70fb4b6a662 Mon Sep 17 00:00:00 2001 From: yaemiku Date: Fri, 3 Sep 2021 00:40:52 +0200 Subject: [PATCH] Prepare for deploy --- .gitignore | 3 ++- puchar/settings.py | 26 +++++++++++++++++++------- requirements.txt | 2 ++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index c30f8d8..3670276 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ db.sqlite3 -media/ \ No newline at end of file +media/ +.env \ No newline at end of file diff --git a/puchar/settings.py b/puchar/settings.py index 6a4a25b..d407f48 100644 --- a/puchar/settings.py +++ b/puchar/settings.py @@ -11,6 +11,10 @@ https://docs.djangoproject.com/en/3.2/ref/settings/ """ from pathlib import Path +from dotenv import load_dotenv +import os + +load_dotenv() # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -20,12 +24,17 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-d&9*2#r2_)aaskh23)tpu!#jyu*e2yyw0ajg-2@25444^5$eov' -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = ['*', 'puchar.lo5.bielsko.pl', 'localhost', '127.0.0.1'] +SECRET_KEY = os.getenv('SECRET_KEY') +EMAIL_BACKEND = os.getenv('EMAIL_BACKEND') +EMAIL_HOST = os.getenv('EMAIL_HOST') +EMAIL_USE_TLS = True +EMAIL_USE_SSL = False +EMAIL_PORT = int(os.getenv('EMAIL_PORT')) +EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER') +EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD') +DEBUG = int(os.getenv('DEBUG')) == 1 +ALLOWED_HOSTS = ['*'] # Application definition @@ -80,8 +89,11 @@ X_FRAME_OPTIONS = 'SAMEORIGIN' DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3' + 'ENGINE': os.getenv('DB_ENGINE'), + 'NAME': os.getenv('DB_NAME'), + 'HOST': os.getenv('DB_HOST'), + 'USER': os.getenv('DB_USER'), + 'PASSWORD': os.getenv('DB_PASSWORD'), } } diff --git a/requirements.txt b/requirements.txt index 7b12107..edec3fb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,5 @@ django-cleanup django-crispy-forms==1.12.0 django-summernote django-crispy-bulma + +python-dotenv