MCPcopy
hub / github.com/django/django / get_ancestor_link

Method get_ancestor_link

django/db/models/options.py:734–752  ·  view source on GitHub ↗

Return the field on the current model which points to the given "ancestor". This is possible an indirect link (a pointer to a parent model, which points, eventually, to the ancestor). Used when constructing table joins for model inheritance. Return None if t

(self, ancestor)

Source from the content-addressed store, hash-verified

732 return list(self.all_parents)
733
734 def get_ancestor_link(self, ancestor):
735 """
736 Return the field on the current model which points to the given
737 "ancestor". This is possible an indirect link (a pointer to a parent
738 model, which points, eventually, to the ancestor). Used when
739 constructing table joins for model inheritance.
740
741 Return None if the model isn't an ancestor of this one.
742 """
743 if ancestor in self.parents:
744 return self.parents[ancestor]
745 for parent in self.parents:
746 # Tries to get a link field from the immediate parent
747 parent_link = parent._meta.get_ancestor_link(ancestor)
748 if parent_link:
749 # In case of a proxied model, the first link
750 # of the chain to the ancestor is that parent
751 # links
752 return self.parents[parent] or parent_link
753
754 def get_path_to_parent(self, parent):
755 """

Calls

no outgoing calls

Tested by 1