Python django.db.models.query_utils.PathInfo() Examples

The following are 30 code examples of django.db.models.query_utils.PathInfo(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.db.models.query_utils , or try the search function .
Example #1
Source File: options.py    From python2017 with MIT License 6 votes vote down vote up
def get_path_to_parent(self, parent):
        """
        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.
        """
        if self.model is parent:
            return []
        # Skip the chain of proxy to the concrete proxied model.
        proxied_model = self.concrete_model
        path = []
        opts = self
        for int_model in self.get_base_chain(parent):
            if int_model is proxied_model:
                opts = int_model._meta
            else:
                final_field = opts.parents[int_model]
                targets = (final_field.remote_field.get_related_field(),)
                opts = int_model._meta
                path.append(PathInfo(final_field.model._meta, opts, targets, final_field, False, True))
        return path 
Example #2
Source File: options.py    From python with Apache License 2.0 6 votes vote down vote up
def get_path_to_parent(self, parent):
        """
        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.
        """
        if self.model is parent:
            return []
        # Skip the chain of proxy to the concrete proxied model.
        proxied_model = self.concrete_model
        path = []
        opts = self
        for int_model in self.get_base_chain(parent):
            if int_model is proxied_model:
                opts = int_model._meta
            else:
                final_field = opts.parents[int_model]
                targets = (final_field.remote_field.get_related_field(),)
                opts = int_model._meta
                path.append(PathInfo(final_field.model._meta, opts, targets, final_field, False, True))
        return path 
Example #3
Source File: related.py    From python with Apache License 2.0 5 votes vote down vote up
def get_reverse_path_info(self):
        """
        Get path from the related model to this field's model.
        """
        opts = self.model._meta
        from_opts = self.remote_field.model._meta
        pathinfos = [PathInfo(from_opts, opts, (opts.pk,), self.remote_field, not self.unique, False)]
        return pathinfos 
Example #4
Source File: empty_join.py    From djongo with GNU Affero General Public License v3.0 5 votes vote down vote up
def get_reverse_path_info(self, filtered_relation=None):
        to_opts = self.model._meta
        from_opts = self.remote_field.model._meta
        return [PathInfo(
            from_opts=from_opts,
            to_opts=to_opts,
            target_fields=(to_opts.pk,),
            join_field=self.remote_field,
            m2m=False,
            direct=False,
            filtered_relation=filtered_relation,
        )] 
Example #5
Source File: empty_join.py    From djongo with GNU Affero General Public License v3.0 5 votes vote down vote up
def get_path_info(self, filtered_relation=None):
        to_opts = self.remote_field.model._meta
        from_opts = self.model._meta
        return [PathInfo(
            from_opts=from_opts,
            to_opts=to_opts,
            target_fields=(to_opts.pk,),
            join_field=self,
            m2m=False,
            direct=False,
            filtered_relation=filtered_relation,
        )] 
Example #6
Source File: empty_join.py    From djongo with GNU Affero General Public License v3.0 5 votes vote down vote up
def get_reverse_path_info(self, filtered_relation=None):
        to_opts = self.model._meta
        from_opts = self.remote_field.model._meta
        return [PathInfo(
            from_opts=from_opts,
            to_opts=to_opts,
            target_fields=(to_opts.pk,),
            join_field=self.remote_field,
            m2m=False,
            direct=False,
            filtered_relation=filtered_relation,
        )] 
Example #7
Source File: empty_join.py    From djongo with GNU Affero General Public License v3.0 5 votes vote down vote up
def get_path_info(self, filtered_relation=None):
        to_opts = self.remote_field.model._meta
        from_opts = self.model._meta
        return [PathInfo(
            from_opts=from_opts,
            to_opts=to_opts,
            target_fields=(to_opts.pk,),
            join_field=self,
            m2m=False,
            direct=False,
            filtered_relation=filtered_relation,
        )] 
Example #8
Source File: related.py    From python2017 with MIT License 5 votes vote down vote up
def get_reverse_path_info(self):
        """
        Get path from the related model to this field's model.
        """
        opts = self.model._meta
        from_opts = self.remote_field.model._meta
        pathinfos = [PathInfo(from_opts, opts, (opts.pk,), self.remote_field, not self.unique, False)]
        return pathinfos 
Example #9
Source File: related.py    From python2017 with MIT License 5 votes vote down vote up
def get_reverse_path_info(self):
        """
        Get path from the related model to this field's model.
        """
        opts = self.model._meta
        from_opts = self.remote_field.model._meta
        pathinfos = [PathInfo(from_opts, opts, (opts.pk,), self.remote_field, not self.unique, False)]
        return pathinfos 
Example #10
Source File: related.py    From python2017 with MIT License 5 votes vote down vote up
def get_path_info(self):
        """
        Get path from this field to the related model.
        """
        opts = self.remote_field.model._meta
        from_opts = self.model._meta
        return [PathInfo(from_opts, opts, self.foreign_related_fields, self, False, True)] 
Example #11
Source File: fields.py    From openhgsenti with Apache License 2.0 5 votes vote down vote up
def get_reverse_path_info(self):
        opts = self.model._meta
        from_opts = self.remote_field.model._meta
        return [PathInfo(from_opts, opts, (opts.pk,), self, not self.unique, False)] 
Example #12
Source File: fields.py    From openhgsenti with Apache License 2.0 5 votes vote down vote up
def get_path_info(self):
        opts = self.remote_field.model._meta
        target = opts.pk
        return [PathInfo(self.model._meta, opts, (target,), self.remote_field, True, False)] 
Example #13
Source File: related.py    From openhgsenti with Apache License 2.0 5 votes vote down vote up
def get_reverse_path_info(self):
        """
        Get path from the related model to this field's model.
        """
        opts = self.model._meta
        from_opts = self.remote_field.model._meta
        pathinfos = [PathInfo(from_opts, opts, (opts.pk,), self.remote_field, not self.unique, False)]
        return pathinfos 
Example #14
Source File: related.py    From openhgsenti with Apache License 2.0 5 votes vote down vote up
def get_reverse_path_info(self):
        """
        Get path from the related model to this field's model.
        """
        opts = self.model._meta
        from_opts = self.remote_field.model._meta
        pathinfos = [PathInfo(from_opts, opts, (opts.pk,), self.remote_field, not self.unique, False)]
        return pathinfos 
Example #15
Source File: related.py    From openhgsenti with Apache License 2.0 5 votes vote down vote up
def get_path_info(self):
        """
        Get path from this field to the related model.
        """
        opts = self.remote_field.model._meta
        from_opts = self.model._meta
        return [PathInfo(from_opts, opts, self.foreign_related_fields, self, False, True)] 
Example #16
Source File: related.py    From python with Apache License 2.0 5 votes vote down vote up
def get_reverse_path_info(self):
        """
        Get path from the related model to this field's model.
        """
        opts = self.model._meta
        from_opts = self.remote_field.model._meta
        pathinfos = [PathInfo(from_opts, opts, (opts.pk,), self.remote_field, not self.unique, False)]
        return pathinfos 
Example #17
Source File: related.py    From GTDWeb with GNU General Public License v2.0 5 votes vote down vote up
def get_path_info(self):
        """
        Get path from this field to the related model.
        """
        opts = self.rel.to._meta
        from_opts = self.model._meta
        return [PathInfo(from_opts, opts, self.foreign_related_fields, self, False, True)] 
Example #18
Source File: related.py    From python with Apache License 2.0 5 votes vote down vote up
def get_path_info(self):
        """
        Get path from this field to the related model.
        """
        opts = self.remote_field.model._meta
        from_opts = self.model._meta
        return [PathInfo(from_opts, opts, self.foreign_related_fields, self, False, True)] 
Example #19
Source File: related.py    From Hands-On-Application-Development-with-PyCharm with MIT License 5 votes vote down vote up
def get_reverse_path_info(self, filtered_relation=None):
        """Get path from the related model to this field's model."""
        opts = self.model._meta
        from_opts = self.remote_field.model._meta
        return [PathInfo(
            from_opts=from_opts,
            to_opts=opts,
            target_fields=(opts.pk,),
            join_field=self.remote_field,
            m2m=not self.unique,
            direct=False,
            filtered_relation=filtered_relation,
        )] 
Example #20
Source File: related.py    From Hands-On-Application-Development-with-PyCharm with MIT License 5 votes vote down vote up
def get_reverse_path_info(self, filtered_relation=None):
        """Get path from the related model to this field's model."""
        opts = self.model._meta
        from_opts = self.remote_field.model._meta
        return [PathInfo(
            from_opts=from_opts,
            to_opts=opts,
            target_fields=(opts.pk,),
            join_field=self.remote_field,
            m2m=not self.unique,
            direct=False,
            filtered_relation=filtered_relation,
        )] 
Example #21
Source File: related.py    From Hands-On-Application-Development-with-PyCharm with MIT License 5 votes vote down vote up
def get_path_info(self, filtered_relation=None):
        """Get path from this field to the related model."""
        opts = self.remote_field.model._meta
        from_opts = self.model._meta
        return [PathInfo(
            from_opts=from_opts,
            to_opts=opts,
            target_fields=self.foreign_related_fields,
            join_field=self,
            m2m=False,
            direct=True,
            filtered_relation=filtered_relation,
        )] 
Example #22
Source File: options.py    From Hands-On-Application-Development-with-PyCharm with MIT License 5 votes vote down vote up
def get_path_to_parent(self, parent):
        """
        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.
        """
        if self.model is parent:
            return []
        # Skip the chain of proxy to the concrete proxied model.
        proxied_model = self.concrete_model
        path = []
        opts = self
        for int_model in self.get_base_chain(parent):
            if int_model is proxied_model:
                opts = int_model._meta
            else:
                final_field = opts.parents[int_model]
                targets = (final_field.remote_field.get_related_field(),)
                opts = int_model._meta
                path.append(PathInfo(
                    from_opts=final_field.model._meta,
                    to_opts=opts,
                    target_fields=targets,
                    join_field=final_field,
                    m2m=False,
                    direct=True,
                    filtered_relation=None,
                ))
        return path 
Example #23
Source File: related.py    From bioforum with MIT License 5 votes vote down vote up
def get_reverse_path_info(self, filtered_relation=None):
        """Get path from the related model to this field's model."""
        opts = self.model._meta
        from_opts = self.remote_field.model._meta
        return [PathInfo(
            from_opts=from_opts,
            to_opts=opts,
            target_fields=(opts.pk,),
            join_field=self.remote_field,
            m2m=not self.unique,
            direct=False,
            filtered_relation=filtered_relation,
        )] 
Example #24
Source File: related.py    From bioforum with MIT License 5 votes vote down vote up
def get_reverse_path_info(self, filtered_relation=None):
        """Get path from the related model to this field's model."""
        opts = self.model._meta
        from_opts = self.remote_field.model._meta
        return [PathInfo(
            from_opts=from_opts,
            to_opts=opts,
            target_fields=(opts.pk,),
            join_field=self.remote_field,
            m2m=not self.unique,
            direct=False,
            filtered_relation=filtered_relation,
        )] 
Example #25
Source File: related.py    From bioforum with MIT License 5 votes vote down vote up
def get_path_info(self, filtered_relation=None):
        """Get path from this field to the related model."""
        opts = self.remote_field.model._meta
        from_opts = self.model._meta
        return [PathInfo(
            from_opts=from_opts,
            to_opts=opts,
            target_fields=self.foreign_related_fields,
            join_field=self,
            m2m=False,
            direct=True,
            filtered_relation=filtered_relation,
        )] 
Example #26
Source File: options.py    From bioforum with MIT License 5 votes vote down vote up
def get_path_to_parent(self, parent):
        """
        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.
        """
        if self.model is parent:
            return []
        # Skip the chain of proxy to the concrete proxied model.
        proxied_model = self.concrete_model
        path = []
        opts = self
        for int_model in self.get_base_chain(parent):
            if int_model is proxied_model:
                opts = int_model._meta
            else:
                final_field = opts.parents[int_model]
                targets = (final_field.remote_field.get_related_field(),)
                opts = int_model._meta
                path.append(PathInfo(
                    from_opts=final_field.model._meta,
                    to_opts=opts,
                    target_fields=targets,
                    join_field=final_field,
                    m2m=False,
                    direct=True,
                    filtered_relation=None,
                ))
        return path 
Example #27
Source File: fields.py    From GTDWeb with GNU General Public License v2.0 5 votes vote down vote up
def get_reverse_path_info(self):
        opts = self.model._meta
        from_opts = self.rel.to._meta
        return [PathInfo(from_opts, opts, (opts.pk,), self, not self.unique, False)] 
Example #28
Source File: fields.py    From GTDWeb with GNU General Public License v2.0 5 votes vote down vote up
def get_path_info(self):
        opts = self.rel.to._meta
        target = opts.pk
        return [PathInfo(self.model._meta, opts, (target,), self.rel, True, False)] 
Example #29
Source File: related.py    From GTDWeb with GNU General Public License v2.0 5 votes vote down vote up
def get_reverse_path_info(self):
        """
        Get path from the related model to this field's model.
        """
        opts = self.model._meta
        from_opts = self.rel.to._meta
        pathinfos = [PathInfo(from_opts, opts, (opts.pk,), self.rel, not self.unique, False)]
        return pathinfos 
Example #30
Source File: related.py    From GTDWeb with GNU General Public License v2.0 5 votes vote down vote up
def get_reverse_path_info(self):
        """
        Get path from the related model to this field's model.
        """
        opts = self.model._meta
        from_opts = self.rel.to._meta
        pathinfos = [PathInfo(from_opts, opts, (opts.pk,), self.rel, not self.unique, False)]
        return pathinfos