mirror of https://github.com/django/django.git
Made Options.get_base_chain() always return a list.
This commit is contained in:
parent
825429c1f7
commit
6bd7ee4eab
|
@ -651,12 +651,12 @@ class Options(object):
|
||||||
|
|
||||||
def get_base_chain(self, model):
|
def get_base_chain(self, model):
|
||||||
"""
|
"""
|
||||||
Returns a list of parent classes leading to 'model' (order from closet
|
Return a list of parent classes leading to `model` (ordered from
|
||||||
to most distant ancestor). This has to handle the case were 'model' is
|
closest to most distant ancestor). This has to handle the case where
|
||||||
a grandparent or even more distant relation.
|
`model` is a grandparent or even more distant relation.
|
||||||
"""
|
"""
|
||||||
if not self.parents:
|
if not self.parents:
|
||||||
return None
|
return []
|
||||||
if model in self.parents:
|
if model in self.parents:
|
||||||
return [model]
|
return [model]
|
||||||
for parent in self.parents:
|
for parent in self.parents:
|
||||||
|
@ -664,7 +664,7 @@ class Options(object):
|
||||||
if res:
|
if res:
|
||||||
res.insert(0, parent)
|
res.insert(0, parent)
|
||||||
return res
|
return res
|
||||||
return None
|
return []
|
||||||
|
|
||||||
def get_parent_list(self):
|
def get_parent_list(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -950,7 +950,7 @@ class Query(object):
|
||||||
if model in seen:
|
if model in seen:
|
||||||
return seen[model]
|
return seen[model]
|
||||||
chain = opts.get_base_chain(model)
|
chain = opts.get_base_chain(model)
|
||||||
if chain is None:
|
if not chain:
|
||||||
return alias
|
return alias
|
||||||
curr_opts = opts
|
curr_opts = opts
|
||||||
for int_model in chain:
|
for int_model in chain:
|
||||||
|
|
Loading…
Reference in New Issue