Skip to content

Commit

Permalink
Merge branch 'arminpatel-separate_settings'
Browse files Browse the repository at this point in the history
  • Loading branch information
arminpatel committed Dec 30, 2023
2 parents f0aa3f1 + a3e715a commit f490135
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
13 changes: 1 addition & 12 deletions backend/core/settings.py → backend/core/settings/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
from pathlib import Path
from dotenv import load_dotenv
import dj_database_url

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand All @@ -15,7 +14,7 @@
SECRET_KEY = os.environ.get('DJANGO_SECRET', 'default')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get('DJANGO_DEBUG', "False").lower == 'true'
DEBUG = os.environ.get('DEBUG') != 'False'

ALLOWED_HOSTS = ['*']
# ALLOWED_HOSTS = os.environ.get('DJANGO_ALLOWED_HOSTS').split(' ')
Expand Down Expand Up @@ -92,16 +91,6 @@
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
# dj_database_url.config(default=os.environ.get('DATABASE_URL'))
# dj_database_url.parse(os.environ.get("DATABASE_URL"))
}
}

DATABASES['default'] = dj_database_url.parse(os.environ.get("DATABASE_URL"))
# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators

Expand Down
10 changes: 10 additions & 0 deletions backend/core/settings/development.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from .base import * # noqa: F403, F401

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
# dj_database_url.config(default=os.environ.get('DATABASE_URL'))
# dj_database_url.parse(os.environ.get("DATABASE_URL"))
}
}
8 changes: 8 additions & 0 deletions backend/core/settings/production.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os

from .base import * # noqa: F403, F401
import dj_database_url

DATABASES = {
'default': dj_database_url.config(default=os.environ.get('DATABASE_URL'))
}
7 changes: 6 additions & 1 deletion backend/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
import os
import sys

from core.settings import base


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
if base.DEBUG:
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings.development')
else:
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings.production')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand Down

0 comments on commit f490135

Please sign in to comment.