Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

split settings into base, develop, production #5

Merged
merged 1 commit into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
release: python manage.py migrate
release: python manage.py migrate --settings=depotcommun.settings.production
web: gunicorn depotcommun.wsgi
2 changes: 1 addition & 1 deletion depotcommun/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'depotcommun.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'depotcommun.settings.production')

application = get_asgi_application()
Empty file.
5 changes: 1 addition & 4 deletions depotcommun/settings.py → depotcommun/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@

from pathlib import Path

import django_heroku

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
BASE_DIR = Path(__file__).resolve().parent.parent.parent


# Quick-start development settings - unsuitable for production
Expand Down Expand Up @@ -128,5 +127,3 @@

STATIC_URL = '/static/'

django_heroku.settings(locals())
Copy link
Owner

@zuckerruebe zuckerruebe Feb 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not also remove the DATABASES= part in base.py?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that would make it consistent.
will you make the change or should I?


17 changes: 17 additions & 0 deletions depotcommun/settings/develop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from .base import *

# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
'default': {
# sqlite database
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': 'depotcommun.db',
# postgres database
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'depot-commun',
'USER': 'postgres',
'PASSWORD': 'password',
}
}
20 changes: 20 additions & 0 deletions depotcommun/settings/production.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from .base import *

# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'depot-commun',
'USER': 'postgres',
'PASSWORD': 'password',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll have to think about removing passwords and so on for production in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Passwords and secret key are properties that should be specified on the server. I think heroku has means to do this. That's what the heroku client library that we are using is meant for isn't it?

'HOST': '127.0.0.1',
'PORT': '5432',
}
}

DEBUG = False

import django_heroku
django_heroku.settings(locals())
2 changes: 1 addition & 1 deletion depotcommun/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'depotcommun.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'depotcommun.settings.production')

application = get_wsgi_application()
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', 'depotcommun.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'depotcommun.settings.develop')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand Down