From 6f9472ed43bcb3894190dc2f49906f795ec7b07f Mon Sep 17 00:00:00 2001 From: chris48s Date: Sun, 3 Dec 2017 15:24:40 +0000 Subject: [PATCH] shim get_version() for django 2 --- .../management/commands/sync_to_sendgrid.py | 10 +++++++++- dc_signup_form/signup_server/models.py | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/dc_signup_form/signup_server/management/commands/sync_to_sendgrid.py b/dc_signup_form/signup_server/management/commands/sync_to_sendgrid.py index f369061..5c467c2 100644 --- a/dc_signup_form/signup_server/management/commands/sync_to_sendgrid.py +++ b/dc_signup_form/signup_server/management/commands/sync_to_sendgrid.py @@ -3,7 +3,15 @@ import time from django.core.management.base import BaseCommand from django.db import connection -from django.db.backends.postgresql_psycopg2.version import get_version + +try: + # django < 2.0 + from django.db.backends.postgresql_psycopg2.version import get_version +except ImportError: + # django >= 2.0 + def get_version(connection): + return connection.pg_version + from django.db.models import Q from dc_signup_form.signup_server.models import SignupQueue from dc_signup_form.signup_server.wrappers import DCSendGridWrapper diff --git a/dc_signup_form/signup_server/models.py b/dc_signup_form/signup_server/models.py index 345acc1..dd302dc 100644 --- a/dc_signup_form/signup_server/models.py +++ b/dc_signup_form/signup_server/models.py @@ -1,7 +1,16 @@ import binascii import os from django.db import models -from django.db.backends.postgresql_psycopg2.version import get_version + +try: + # django < 2.0 + from django.db.backends.postgresql_psycopg2.version import get_version +except ImportError: + # django >= 2.0 + from django.db import connection + def get_version(connection): + return connection.pg_version + from django.contrib.postgres.fields import JSONField