Compare commits

...

2 Commits

Author SHA1 Message Date
85217e4e9c
logging settings comment blocked in lieu of notif systems 2022-01-08 14:51:06 +05:30
79f6d10d9d
db settings 2022-01-08 14:44:43 +05:30

View File

@ -11,10 +11,26 @@ https://docs.djangoproject.com/en/4.0/ref/settings/
"""
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
## ENVARS ##
POSTGRES_DB = os.getenv('POSTGRES_DB')
POSTGRES_USER = os.getenv('POSTGRES_USER')
POSTGRES_PASSWORD = os.getenv('POSTGRES_PASSWORD')
POSTGRES_HOST = os.getenv('POSTGRES_HOST')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
if os.getenv('DEBUG') == 'True':
DEBUG = True
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
@ -80,11 +96,23 @@ WSGI_APPLICATION = 'website.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': POSTGRES_DB,
'USER': POSTGRES_USER,
'PASSWORD': POSTGRES_PASSWORD,
'HOST': POSTGRES_HOST,
'PORT': '5432',
}
}
if os.getenv('DEV') == 'true':
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
@ -134,4 +162,27 @@ REST_FRAMEWORK = {
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
]
}
}
# LOGGING = {
# 'version': 1,
# 'disable_existing_loggers': False,
# 'handlers': {
# 'file': {
# 'level': 'DEBUG',
# 'class': 'logging.FileHandler',
# 'filename': './debug.log',
# },
# 'error_file': {
# 'level': 'ERROR',
# 'class': 'logging.FileHandler',
# 'filename': './error.log',
# },
# },
# 'loggers': {
# 'django': {
# 'handlers': ['file', 'error_file'],
# 'propagate': True,
# },
# },
# }