summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2012-12-21 20:56:04 +0200
committerAnssi Kääriäinen <akaariai@gmail.com>2012-12-21 20:56:04 +0200
commita0155f35343afbfd9e98ab9aa4615f06780f697e (patch)
tree9fb625368b2a7849b82282817785aee9e6deada8
parent9e7183073f64e541587e8dcfd8bb3ddeb47f8162 (diff)
[1.5.x] Refactored proxy model skipping in get_default_columns()
The refactoring allows custom subclasses to use different default columns than the base model.
-rw-r--r--django/db/models/sql/compiler.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index 30b9bed8b4..7ea4cd700a 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -255,8 +255,6 @@ class SQLCompiler(object):
result = []
if opts is None:
opts = self.query.model._meta
- # Skip all proxy to the root proxied model
- opts = opts.concrete_model._meta
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
aliases = set()
@@ -265,6 +263,10 @@ class SQLCompiler(object):
if start_alias:
seen = {None: start_alias}
for field, model in opts.get_fields_with_model():
+ # For local fields (even if through proxy) the model should
+ # be None.
+ if model == opts.concrete_model:
+ model = None
if local_only and model is not None:
continue
if start_alias: