Skip to content

Commit

Permalink
refac: prepare project for prod
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinKweyu committed Feb 5, 2023
1 parent 70c779b commit aabaf90
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 26 deletions.
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Empty file added masomo/config/__init__.py
Empty file.
29 changes: 4 additions & 25 deletions masomo/settings.py → masomo/config/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
17 changes: 17 additions & 0 deletions masomo/config/dev.py
Original file line number Diff line number Diff line change
@@ -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"),
}
}
24 changes: 24 additions & 0 deletions masomo/config/prod.py
Original file line number Diff line number Diff line change
@@ -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 protected]"),)

# 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"),
}
}
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit aabaf90

Please sign in to comment.