8000 import was causing a depracation warning · dcramer/django-devserver@4c5864a · GitHub
[go: up one dir, main page]

Skip to content

Commit 4c5864a

Browse files
committed
import was causing a depracation warning
1 parent e6c882f commit 4c5864a

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

devserver/modules/sql.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
from django.db import connection
1313
connections = {'default': connection}
1414

15-
from django.db.backends import util
15+
try:
16+
from django.db.backends import utils # renamed in django 1.7
17+
except ImportError:
18+
from django.db.backends import util as utils # removed in django 1.9
1619
from django.conf import settings as django_settings
1720
#from django.template import Node
1821

@@ -52,9 +55,9 @@ def truncate_sql(sql, aggregates=True):
5255
import django
5356
version = float('.'.join([str(x) for x in django.VERSION[:2]]))
5457
if version >= 1.6:
55-
DatabaseStatTracker = util.CursorWrapper
58+
DatabaseStatTracker = utils.CursorWrapper
5659
else:
57-
DatabaseStatTracker = util.CursorDebugWrapper
60+
DatabaseStatTracker = utils.CursorDebugWrapper
5861

5962

6063
class DatabaseStatTracker(DatabaseStatTracker):
@@ -126,14 +129,14 @@ class SQLRealTimeModule(DevServerModule):
126129
logger_name = 'sql'
127130

128131
def process_init(self, request):
129-
if not issubclass(util.CursorDebugWrapper, DatabaseStatTracker):
130-
self.old_cursor = util.CursorDebugWrapper
131-
util.CursorDebugWrapper = DatabaseStatTracker
132+
if not issubclass(utils.CursorDebugWrapper, DatabaseStatTracker):
133+
self.old_cursor = utils.CursorDebugWrapper
134+
utils.CursorDebugWrapper = DatabaseStatTracker
132135
DatabaseStatTracker.logger = self.logger
133136

134137
def process_complete(self, request):
135-
if issubclass(util.CursorDebugWrapper, DatabaseStatTracker):
136-
util.CursorDebugWrapper = self.old_cursor
138+
if issubclass(utils.CursorDebugWrapper, DatabaseStatTracker):
139+
utils.CursorDebugWrapper = self.old_cursor
137140

138141

139142
class SQLSummaryModule(DevServerModule):

0 commit comments

Comments
 (0)
0