diff --git a/django/db/backends/creation.py b/django/db/backends/creation.py index 8cfca3b8503..8f4958867b8 100644 --- a/django/db/backends/creation.py +++ b/django/db/backends/creation.py @@ -61,7 +61,7 @@ class BaseDatabaseCreation(object): if f.rel: ref_output, pending = self.sql_for_inline_foreign_key_references(f, known_models, style) if pending: - pr = pending_references.setdefault(f.rel.to, []).append((model, f)) + pending_references.setdefault(f.rel.to, []).append((model, f)) else: field_output.extend(ref_output) table_output.append(' '.join(field_output)) @@ -267,7 +267,7 @@ class BaseDatabaseCreation(object): # Get a cursor (even though we don't need one yet). This has # the side effect of initializing the test database. - cursor = self.connection.cursor() + self.connection.cursor() return test_database_name diff --git a/django/db/models/base.py b/django/db/models/base.py index 4b3220b514a..b5ce39e3d5a 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -474,7 +474,6 @@ class Model(object): ('raw', 'cls', and 'origin'). """ using = using or router.db_for_write(self.__class__, instance=self) - connection = connections[using] assert not (force_insert and force_update) if cls is None: cls = self.__class__ diff --git a/django/db/models/query.py b/django/db/models/query.py index 0e1a1b31b41..246b155b0c5 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -9,7 +9,7 @@ from django.db.models.fields import AutoField from django.db.models.query_utils import (Q, select_related_descend, deferred_class_factory, InvalidQuery) from django.db.models.deletion import Collector -from django.db.models import signals, sql +from django.db.models import sql from django.utils.functional import partition # Used to control how many objects are worked with at once in some cases (e.g. diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 9ddcfc63f9c..6bf7de2e210 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -1,14 +1,13 @@ from itertools import izip from django.core.exceptions import FieldError -from django.db import connections from django.db import transaction from django.db.backends.util import truncate_name +from django.db.models.query_utils import select_related_descend from django.db.models.sql.constants import * from django.db.models.sql.datastructures import EmptyResultSet from django.db.models.sql.expressions import SQLEvaluator -from django.db.models.sql.query import (get_proxied_model, get_order_dir, - select_related_descend, Query) +from django.db.models.sql.query import get_proxied_model, get_order_dir, Query from django.db.utils import DatabaseError @@ -875,8 +874,6 @@ class SQLUpdateCompiler(SQLCompiler): Creates the SQL for this query. Returns the SQL string and list of parameters. """ - from django.db.models.base import Model - self.pre_sql_setup() if not self.query.values: return '', () diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 101d4ac7a54..61fd2be40b3 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -15,7 +15,7 @@ from django.utils.tree import Node from django.db import connections, DEFAULT_DB_ALIAS from django.db.models import signals from django.db.models.fields import FieldDoesNotExist -from django.db.models.query_utils import select_related_descend, InvalidQuery +from django.db.models.query_utils import InvalidQuery from django.db.models.sql import aggregates as base_aggregates_module from django.db.models.sql.constants import * from django.db.models.sql.datastructures import EmptyResultSet, Empty, MultiJoin @@ -567,7 +567,6 @@ class Query(object): field_names, defer = self.deferred_loading if not field_names: return - columns = set() orig_opts = self.model._meta seen = {} if orig_opts.proxy: