Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[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.
  • Loading branch information...
commit a0155f35343afbfd9e98ab9aa4615f06780f697e 1 parent 9e71830
@akaariai akaariai authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 django/db/models/sql/compiler.py
View
6 django/db/models/sql/compiler.py
@@ -255,8 +255,6 @@ def get_default_columns(self, with_aliases=False, col_aliases=None,
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 @@ def get_default_columns(self, with_aliases=False, col_aliases=None,
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:
Please sign in to comment.
Something went wrong with that request. Please try again.