add .env, wired database to settings, updated readme

This commit is contained in:
Sam
2021-01-21 10:29:35 +00:00
parent e1a92f2273
commit adb1371599
5 changed files with 51 additions and 23 deletions

View File

@@ -12,9 +12,16 @@ https://docs.djangoproject.com/en/2.2/ref/settings/
import os
import dotenv
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Get variables from .env
dotenv.read_dotenv(
dotenv=os.path.join(BASE_DIR, '.env'),
override=True
)
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
@@ -37,6 +44,13 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'core',
'companies',
'products',
'history',
'stats',
]
MIDDLEWARE = [
@@ -73,11 +87,16 @@ WSGI_APPLICATION = 'back_latienda.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
# Databases configuration
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.getenv('DB_NAME'),
'USER': os.getenv('DB_USER'),
'PASSWORD': os.getenv('DB_PASSWORD'),
'HOST': os.getenv('DB_HOST', 'localhost'),
'PORT': os.getenv('DB_PORT', '5432'),
},
}