Skip to content
Snippets Groups Projects
Commit d11dcbc3 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

moved secret settings to seperate file and added loader

parent 95ed4a55
No related branches found
No related tags found
No related merge requests found
Pipeline #
secrets.json
db.sqlite3
*.pyc
.coverage
"""
Django settings for fractalis project.
Generated by 'django-admin startproject' using Django 1.9.1.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import os
import json
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__)))
BASE_DIR = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
SECRETS_FILE = os.path.join(BASE_DIR, 'fractalis', 'settings', 'secrets.json')
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
with open(SECRETS_FILE) as f:
secrets = json.loads(f.read())
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '1)3!n4xw*0rt*s3395$pcx8ocngr3g__0a$86@*xh56_f@*t86'
def get_secret(setting, secrets=secrets):
"""Get the secret variable or return excplicit exception."""
try:
return secrets[setting]
except KeyError:
error_msg = "Variable {0} not found in 'secrets.json'".format(setting)
raise ImproperlyConfigured(error_msg)
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
SECRET_KEY = get_secret("SECRET_KEY")
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment