Skip to content

Commit

Permalink
Change slightly the PostgreSQL backend compatibility code.
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandBordage committed Jul 21, 2016
1 parent 944ebb9 commit b9f84f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
8 changes: 3 additions & 5 deletions cachalot/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django import VERSION as django_version
from django.apps import AppConfig
from django.conf import settings
from django.core.checks import register, Tags, Error, Warning
Expand All @@ -8,8 +7,10 @@

VALID_DATABASE_ENGINES = {
'django.db.backends.sqlite3',
'django.db.backends.postgresql_psycopg2',
'django.db.backends.postgresql',
'django.db.backends.mysql',
# TODO: Remove when we drop Django 1.8 support.
'django.db.backends.postgresql_psycopg2',

# GeoDjango
'django.contrib.gis.db.backends.spatialite',
Expand All @@ -23,9 +24,6 @@
'transaction_hooks.backends.mysql',
}

if django_version[:2] >= (1, 9):
VALID_DATABASE_ENGINES.add('django.db.backends.postgresql')


VALID_CACHE_BACKENDS = {
'django.core.cache.backends.dummy.DummyCache',
Expand Down
10 changes: 4 additions & 6 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@
from __future__ import unicode_literals
import os


if django_version[:2] >= (1, 9):
POSTGRES_ENGINE = 'django.db.backends.postgresql'
else:
POSTGRES_ENGINE = 'django.db.backends.postgresql_psycopg2'
from django import VERSION as django_version

DATABASES = {
'sqlite3': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'cachalot.sqlite3',
},
'postgresql': {
'ENGINE': POSTGRES_ENGINE,
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'cachalot',
'USER': 'cachalot',
},
Expand All @@ -25,6 +21,8 @@
'USER': 'root',
},
}
if django_version[:2] == (1, 8):
DATABASES['postgresql']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
for alias in DATABASES:
test_db_name = 'test_' + DATABASES[alias]['NAME']
DATABASES[alias]['TEST'] = {'NAME': test_db_name}
Expand Down

0 comments on commit b9f84f8

Please sign in to comment.