From 431bc2aa883ea82a701e5862ff4ca794010f2f4a Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Sat, 15 Feb 2020 15:47:31 +0100 Subject: [PATCH] Move settings that need to be customized out of default settings file --- .gitignore | 1 + expcs/custom_settings.dist.py | 14 ++++++++++++++ expcs/settings.py | 18 ++++++++++-------- 3 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 expcs/custom_settings.dist.py diff --git a/.gitignore b/.gitignore index d7b1d8f..4c46512 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ __pycache__ *.pyc migrations/ +expcs/custom_settings.py \ No newline at end of file diff --git a/expcs/custom_settings.dist.py b/expcs/custom_settings.dist.py new file mode 100644 index 0000000..3001f0b --- /dev/null +++ b/expcs/custom_settings.dist.py @@ -0,0 +1,14 @@ +# Secret Key: Replace this by a long random string. +# You can use django.core.management.utils.get_random_secret_key to generate one. + +SECRET_KEY = "changeme" + +# Database settings +# This application is tested only with MariaDB/MySQL. +# You will have to edit settings.py if you want to use Postgres, SQLite, etc. + +DB_HOST = "localhost" +DB_PORT = 3306 +DB_USER = "expcs" +DB_PASS = "secret" +DB_NAME = "expcs" \ No newline at end of file diff --git a/expcs/settings.py b/expcs/settings.py index e387def..096c6b5 100644 --- a/expcs/settings.py +++ b/expcs/settings.py @@ -12,21 +12,18 @@ https://docs.djangoproject.com/en/3.0/ref/settings/ import os +from expcs.custom_settings import * + # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'v))#wh%^fu%zq6jy6p50-ywc$s)b0$611honu0j!@*p%_!w1h!' - # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] - +ALLOWED_HOSTS = ["*"] # Let the web server handle that. That's its job. # Application definition @@ -37,6 +34,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'dbsettings', ] MIDDLEWARE = [ @@ -75,8 +73,12 @@ WSGI_APPLICATION = 'expcs.wsgi.application' DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + 'ENGINE': 'django.db.backends.mysql', + 'NAME': DB_NAME, + 'USER': DB_USER, + 'PASSWORD': DB_PASS, + 'HOST': DB_HOST, + 'PORT': str(DB_PORT), } }