Merge pull request #27 from IcyNet/config

Add a config file
This commit is contained in:
Tsa6 2017-09-21 17:32:38 -04:00 committed by GitHub
commit bdbab9b6ad
3 changed files with 24 additions and 5 deletions

View File

@ -10,7 +10,14 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import dj_database_url
import os
import configparser
import warnings
config = configparser.ConfigParser()
config.read('options.ini')
options = config['General']
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -20,7 +27,10 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '#(5u4*zj+ppjmsa^8mu_e%$0zpou(&9vu^q02g4icb%eu%3qe8'
SECRET_KEY = options.get('secret_key', '5up3r s3cr3t k3y')
if '5up3r s3cr3t k3y' == SECRET_KEY:
warnings.warn("Using a default secret_key, change this in options.ini for production!")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
@ -77,10 +87,7 @@ WSGI_APPLICATION = 'EpisodesCommunity.wsgi.application'
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
'default': dj_database_url.parse(options.get("database", 'sqlite:///database.sqlite3'))
}

11
options_example.ini Normal file
View File

@ -0,0 +1,11 @@
# Copy this file to options.ini to change settings
[General]
# You MUST change this for production. Not doing so is a major vulnerability
secret_key=5up3r s3cr3t k3y
#Changes where the site stores it's data
#See https://github.com/kennethreitz/dj-database-url
#For configuration details
database=sqlite:///database.sqlite3

View File

@ -1,2 +1,3 @@
Django==1.11.4
Pillow=4.2.1
dj-database-url==0.4.2