MCPcopy
hub / github.com/django/django / get_base_chain

Method get_base_chain

django/db/models/options.py:697–712  ·  view source on GitHub ↗

Return a list of parent classes leading to `model` (ordered from closest to most distant ancestor). This has to handle the case where `model` is a grandparent or even more distant relation.

(self, model)

Source from the content-addressed store, hash-verified

695 )
696
697 def get_base_chain(self, model):
698 """
699 Return a list of parent classes leading to `model` (ordered from
700 closest to most distant ancestor). This has to handle the case where
701 `model` is a grandparent or even more distant relation.
702 """
703 if not self.parents:
704 return []
705 if model in self.parents:
706 return [model]
707 for parent in self.parents:
708 res = parent._meta.get_base_chain(model)
709 if res:
710 res.insert(0, parent)
711 return res
712 return []
713
714 @cached_property
715 def all_parents(self):

Callers 3

get_path_to_parentMethod · 0.95
get_path_from_parentMethod · 0.80
join_parent_modelMethod · 0.80

Calls 1

insertMethod · 0.80

Tested by

no test coverage detected