MCPcopy
hub / github.com/django/django / get_path_to_parent

Method get_path_to_parent

django/db/models/options.py:754–784  ·  view source on GitHub ↗

Return a list of PathInfos containing the path from the current model to the parent model, or an empty list if parent is not a parent of the current model.

(self, parent)

Source from the content-addressed store, hash-verified

752 return self.parents[parent] or parent_link
753
754 def get_path_to_parent(self, parent):
755 """
756 Return a list of PathInfos containing the path from the current
757 model to the parent model, or an empty list if parent is not a
758 parent of the current model.
759 """
760 if self.model is parent:
761 return []
762 # Skip the chain of proxy to the concrete proxied model.
763 proxied_model = self.concrete_model
764 path = []
765 opts = self
766 for int_model in self.get_base_chain(parent):
767 if int_model is proxied_model:
768 opts = int_model._meta
769 else:
770 final_field = opts.parents[int_model]
771 targets = (final_field.remote_field.get_related_field(),)
772 opts = int_model._meta
773 path.append(
774 PathInfo(
775 from_opts=final_field.model._meta,
776 to_opts=opts,
777 target_fields=targets,
778 join_field=final_field,
779 m2m=False,
780 direct=True,
781 filtered_relation=None,
782 )
783 )
784 return path
785
786 def get_path_from_parent(self, parent):
787 """

Callers 3

pre_sql_setupMethod · 0.80
names_to_pathMethod · 0.80
_get_path_infoMethod · 0.80

Calls 3

get_base_chainMethod · 0.95
get_related_fieldMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected