Fix DB issue
This commit is contained in:
@ -10,30 +10,11 @@ For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/2.1/ref/settings/
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
# Loads json files with secrets. Follow this example to create your own secrets
|
||||
# file with SECRET_KEY and other information.
|
||||
# Example https://stackoverflow.com/a/42077576
|
||||
with open(os.path.join(BASE_DIR, 'secrets.json')) as secrets_file:
|
||||
secrets = json.load(secrets_file)
|
||||
|
||||
|
||||
def get_secret(setting, secrets=secrets):
|
||||
"""Get secret setting or fail with ImproperlyConfigured"""
|
||||
try:
|
||||
return secrets[setting]
|
||||
except KeyError:
|
||||
raise ImproperlyConfigured("Set the {} setting".format(setting))
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
|
||||
|
||||
@ -41,7 +22,7 @@ def get_secret(setting, secrets=secrets):
|
||||
# This is just some random genearted key to test the App. If you want to set up
|
||||
# your own running public version of this app replace this key with an new one
|
||||
# that you will keep secret!
|
||||
SECRET_KEY = get_secret("SECRET_KEY")
|
||||
SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard to guess string'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
@ -106,12 +87,13 @@ WSGI_APPLICATION = 'bundesdata_app.wsgi.application'
|
||||
# Change NAME, USER and PASSWORD details before deploying your own public
|
||||
# version of this app. Or use your onw secrets.json file. Explanation found can
|
||||
# be foudn here: https://stackoverflow.com/a/42077576
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': get_secret("DB_NAME"),
|
||||
'USER': get_secret("DB_USER"),
|
||||
'PASSWORD': get_secret("DB_PASSWORD"),
|
||||
'NAME': os.environ.get("POSTGRES_DB_NAME"),
|
||||
'USER': os.environ.get("POSTGRES_USER"),
|
||||
'PASSWORD': os.environ.get("POSTGRES_PASSWORD"),
|
||||
'HOST': 'db',
|
||||
'PORT': '5432',
|
||||
}
|
||||
|
@ -1,7 +0,0 @@
|
||||
{
|
||||
"_comment": "DO not use these values in production! This is an example for development!",
|
||||
"SECRET_KEY": "=7n(1!he%todz-)jo))$upf0(vor9v9ke5rn&fli%6l562!_=0",
|
||||
"DB_PASSWORD": "v3ry53cr3t",
|
||||
"DB_USER": "bundesdata_app_user",
|
||||
"DB_NAME": "bundesdata_db"
|
||||
}
|
Reference in New Issue
Block a user