MCPcopy
hub / github.com/django/django / _traverse_ancestors

Function _traverse_ancestors

django/db/models/fields/related_descriptors.py:120–129  ·  view source on GitHub ↗
(model, starting_instance)

Source from the content-addressed store, hash-verified

118
119
120def _traverse_ancestors(model, starting_instance):
121 current_instance = starting_instance
122 while current_instance is not None:
123 ancestor_link = current_instance._meta.get_ancestor_link(model)
124 if not ancestor_link:
125 yield current_instance, None
126 break
127 ancestor = ancestor_link.get_cached_value(current_instance, None)
128 yield current_instance, ancestor
129 current_instance = ancestor
130
131
132class ForwardManyToOneDescriptor:

Callers 3

__get__Method · 0.85
get_prefetch_cacheMethod · 0.85

Calls 2

get_ancestor_linkMethod · 0.80
get_cached_valueMethod · 0.80

Tested by

no test coverage detected