diff --git a/manage.py b/manage.py index b5edb78..369fab6 100755 --- a/manage.py +++ b/manage.py @@ -6,7 +6,7 @@ def main(): """Run administrative tasks.""" - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "masomo.settings") + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "masomo.config.dev") try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/masomo/config/__init__.py b/masomo/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/masomo/settings.py b/masomo/config/base.py similarity index 82% rename from masomo/settings.py rename to masomo/config/base.py index 20b00fe..4190c74 100644 --- a/masomo/settings.py +++ b/masomo/config/base.py @@ -10,22 +10,12 @@ https://docs.djangoproject.com/en/4.1/ref/settings/ """ +import os from pathlib import Path -# Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve().parent.parent - - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = "django-insecure-l5#*$v6%ntl7w19$w&(fq!dx(_9m%6q%%&$yh-nn-h$1ty-y7m" - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = ["*"] +BASE_DIR = os.path.dirname( + os.path.dirname(os.path.abspath(os.path.join(__file__, os.pardir))) +) # Application definition @@ -82,17 +72,6 @@ WSGI_APPLICATION = "masomo.wsgi.application" -# Database -# https://docs.djangoproject.com/en/4.1/ref/settings/#databases - -DATABASES = { - "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": BASE_DIR / "db.sqlite3", - } -} - - # Password validation # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators diff --git a/masomo/config/dev.py b/masomo/config/dev.py new file mode 100644 index 0000000..40bdaa1 --- /dev/null +++ b/masomo/config/dev.py @@ -0,0 +1,17 @@ +import os + +from .base import * + +SECRET_KEY = "django-insecure-l5#*$v6%ntl7w19$w&(fq!dx(_9m%6q%%&$yh-nn-h$1ty-y7m" + +DEBUG = True + +ALLOWED_HOSTS = ["*"] + + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": os.path.join(BASE_DIR, "db.sqlite3"), + } +} diff --git a/masomo/config/prod.py b/masomo/config/prod.py new file mode 100644 index 0000000..3af7528 --- /dev/null +++ b/masomo/config/prod.py @@ -0,0 +1,24 @@ +import os + +from .base import * + +# Todo replace this with your own secret key +SECRET_KEY = os.getenv( + "SECRET_KEY", "django-insecure-l5#*$v6%ntl7w19$w&(fq!dx(_9m%6q%%&$yh-nn-h$1ty-y7m" +) + +DEBUG = False +ADMINS = (("Masomo Administrator", "email@masomo.com"),) + +# Todo replace this with your domain settings + +ALLOWED_HOSTS = ["*"] + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.postgresql", + "NAME": os.getenv("DATABASE_NAME", "masomo"), + "USER": os.getenv("DATABASE_USER", "masomo"), + "PASSWORD": os.getenv("DATABASE_PASSWORD", "masomo"), + } +} diff --git a/requirements.txt b/requirements.txt index 9c71ed0..e02879c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,6 +17,7 @@ mypy-extensions==0.4.3 pathspec==0.10.3 Pillow==9.4.0 platformdirs==2.6.2 +psycopg2-binary==2.9.5 pymemcache==4.0.0 python-memcached==1.59 pytz==2022.7.1 @@ -26,3 +27,4 @@ soupsieve==2.3.2.post1 sqlparse==0.4.3 tomli==2.0.1 urllib3==1.26.13 +uWSGI==2.0.21