Skip to content

Commit 147e1db

Browse files
committed
Allow easy switching between sqlite3 and postgresql in settings.py
1 parent fb5eb05 commit 147e1db

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

issue_tracker/settings.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
Django settings for issue_tracker project.
33
44
Generated by 'django-admin startproject' using Django 1.11.24.
5-
6-
For more information on this file, see
7-
https://docs.djangoproject.com/en/1.11/topics/settings/
8-
9-
For the full list of settings and their values, see
10-
https://docs.djangoproject.com/en/1.11/ref/settings/
115
"""
126

137
import os
@@ -16,29 +10,26 @@
1610

1711
if os.environ.get('DEVELOPMENT'):
1812
development = True
13+
print('DEVELOPMENT=TRUE')
1914
else:
2015
development = False
16+
print('DEVELOPMENT=FALSE')
2117

2218

2319
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
2420
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
2521

26-
27-
# Quick-start development settings - unsuitable for production
28-
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
29-
3022
# SECURITY WARNING: keep the secret key used in production secret!
3123
SECRET_KEY = os.environ.get('SECRET_KEY')
3224

33-
# SECURITY WARNING: don't run with debug turned on in production!
34-
DEBUG = development
25+
# DEBUG = development
26+
DEBUG = True
3527

36-
ALLOWED_HOSTS = ['http://localhost:8000/',
28+
ALLOWED_HOSTS = ['localhost',
3729
os.environ.get('HOSTNAME'),
3830
]
3931

4032
# Application definition
41-
4233
INSTALLED_APPS = [
4334
'django.contrib.admin',
4435
'django.contrib.auth',
@@ -92,15 +83,15 @@
9283
# Database
9384
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
9485
if development:
95-
# sqlite3
86+
print('DATABASE: SQLITE3')
9687
DATABASES = {
9788
'default': {
9889
'ENGINE': 'django.db.backends.sqlite3',
9990
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
10091
}
10192
}
10293
else:
103-
# Postgresql
94+
print('DATABASE: POSTGRESQL')
10495
DATABASES = {
10596
'default': dj_database_url.parse(os.environ.get('DATABASE_URL'))
10697
}

0 commit comments

Comments
 (0)