Skip to content

Commit a9eaae5

Browse files
committed
if else for databases for travis
1 parent ba48862 commit a9eaae5

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

issue_tracker/settings.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,36 @@
8282
WSGI_APPLICATION = 'issue_tracker.wsgi.application'
8383

8484
# Database
85-
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
86-
if development:
87-
print('DATABASE: SQLITE3')
85+
# if development:
86+
# print('DATABASE: SQLITE3')
87+
# DATABASES = {
88+
# 'default': {
89+
# 'ENGINE': 'django.db.backends.sqlite3',
90+
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
91+
# }
92+
# }
93+
# else:
94+
# print('DATABASE: POSTGRESQL')
95+
# DATABASES = {
96+
# 'default': dj_database_url.parse(os.environ.get('DATABASE_URL'))
97+
# }
98+
99+
if "DATABASE_URL" in os.environ and development == False:
100+
print('Database URL found. Using POSTGRESQL')
101+
DATABASES = {
102+
'default': dj_database_url.parse(os.environ.get('DATABASE_URL'))
103+
}
104+
else:
105+
print("Database URL not found. Using SQLite instead.")
88106
DATABASES = {
89107
'default': {
90108
'ENGINE': 'django.db.backends.sqlite3',
91109
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
92110
}
93111
}
94-
else:
95-
print('DATABASE: POSTGRESQL')
96-
DATABASES = {
97-
'default': dj_database_url.parse(os.environ.get('DATABASE_URL'))
98-
}
112+
99113

100114
# Password validation
101-
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
102115

103116
AUTH_PASSWORD_VALIDATORS = [
104117
{
@@ -117,7 +130,6 @@
117130

118131

119132
# Internationalization
120-
# https://docs.djangoproject.com/en/1.11/topics/i18n/
121133

122134
LANGUAGE_CODE = 'en-us'
123135

0 commit comments

Comments
 (0)