[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.
This commit is contained in:
parent
9e7183073f
commit
a0155f3534
@ -255,8 +255,6 @@ class SQLCompiler(object):
|
|||||||
result = []
|
result = []
|
||||||
if opts is None:
|
if opts is None:
|
||||||
opts = self.query.model._meta
|
opts = self.query.model._meta
|
||||||
# Skip all proxy to the root proxied model
|
|
||||||
opts = opts.concrete_model._meta
|
|
||||||
qn = self.quote_name_unless_alias
|
qn = self.quote_name_unless_alias
|
||||||
qn2 = self.connection.ops.quote_name
|
qn2 = self.connection.ops.quote_name
|
||||||
aliases = set()
|
aliases = set()
|
||||||
@ -265,6 +263,10 @@ class SQLCompiler(object):
|
|||||||
if start_alias:
|
if start_alias:
|
||||||
seen = {None: start_alias}
|
seen = {None: start_alias}
|
||||||
for field, model in opts.get_fields_with_model():
|
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:
|
if local_only and model is not None:
|
||||||
continue
|
continue
|
||||||
if start_alias:
|
if start_alias:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user