Return a list of PathInfos containing the path from the parent model to the current model, or an empty list if parent is not a parent of the current model.
(self, parent)
| 784 | return path |
| 785 | |
| 786 | def get_path_from_parent(self, parent): |
| 787 | """ |
| 788 | Return a list of PathInfos containing the path from the parent |
| 789 | model to the current model, or an empty list if parent is not a |
| 790 | parent of the current model. |
| 791 | """ |
| 792 | if self.model is parent: |
| 793 | return [] |
| 794 | model = self.concrete_model |
| 795 | # Get a reversed base chain including both the current and parent |
| 796 | # models. |
| 797 | chain = model._meta.get_base_chain(parent) |
| 798 | chain.reverse() |
| 799 | chain.append(model) |
| 800 | # Construct a list of the PathInfos between models in chain. |
| 801 | path = [] |
| 802 | for i, ancestor in enumerate(chain[:-1]): |
| 803 | child = chain[i + 1] |
| 804 | link = child._meta.get_ancestor_link(ancestor) |
| 805 | path.extend(link.reverse_path_infos) |
| 806 | return path |
| 807 | |
| 808 | def _populate_directed_relation_graph(self): |
| 809 | """ |
no test coverage detected