From 0caa826a971f5fbde7696f9520e5ef9439e7b500 Mon Sep 17 00:00:00 2001 From: Tim Schilling Date: Fri, 31 Jan 2020 10:01:32 -0600 Subject: [PATCH] Only use postgres CursorDebugWrapper with Django 3 --- debug_toolbar/management/commands/debugsqlshell.py | 3 ++- tests/commands/test_debugsqlshell.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/debug_toolbar/management/commands/debugsqlshell.py b/debug_toolbar/management/commands/debugsqlshell.py index a532ea5ba..78e09e27d 100644 --- a/debug_toolbar/management/commands/debugsqlshell.py +++ b/debug_toolbar/management/commands/debugsqlshell.py @@ -1,10 +1,11 @@ from time import time +import django import sqlparse from django.core.management.commands.shell import Command # noqa from django.db import connection -if connection.vendor == "postgresql": +if connection.vendor == "postgresql" and django.VERSION >= (3, 0, 0): from django.db.backends.postgresql import base as base_module else: from django.db.backends import utils as base_module diff --git a/tests/commands/test_debugsqlshell.py b/tests/commands/test_debugsqlshell.py index 9939c5ca9..9520d0dd8 100644 --- a/tests/commands/test_debugsqlshell.py +++ b/tests/commands/test_debugsqlshell.py @@ -1,13 +1,14 @@ import io import sys +import django from django.contrib.auth.models import User from django.core import management from django.db import connection from django.test import TestCase from django.test.utils import override_settings -if connection.vendor == "postgresql": +if connection.vendor == "postgresql" and django.VERSION >= (3, 0, 0): from django.db.backends.postgresql import base as base_module else: from django.db.backends import utils as base_module