本文整理汇总了Python中django.db.models.query_utils.PathInfo方法的典型用法代码示例。如果您正苦于以下问题:Python query_utils.PathInfo方法的具体用法?Python query_utils.PathInfo怎么用?Python query_utils.PathInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.db.models.query_utils
的用法示例。
在下文中一共展示了query_utils.PathInfo方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_path_to_parent
# 需要导入模块: from django.db.models import query_utils [as 别名]
# 或者: from django.db.models.query_utils import PathInfo [as 别名]
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
示例2: get_path_info
# 需要导入模块: from django.db.models import query_utils [as 别名]
# 或者: from django.db.models.query_utils import PathInfo [as 别名]
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)]
示例3: get_reverse_path_info
# 需要导入模块: from django.db.models import query_utils [as 别名]
# 或者: from django.db.models.query_utils import PathInfo [as 别名]
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
示例4: get_path_info
# 需要导入模块: from django.db.models import query_utils [as 别名]
# 或者: from django.db.models.query_utils import PathInfo [as 别名]
def get_path_info(self):
opts = self.rel.to._meta
target = opts.pk
return [PathInfo(self.model._meta, opts, (target,), self.rel, True, False)]
示例5: get_reverse_path_info
# 需要导入模块: from django.db.models import query_utils [as 别名]
# 或者: from django.db.models.query_utils import PathInfo [as 别名]
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)]
示例6: get_path_to_parent
# 需要导入模块: from django.db.models import query_utils [as 别名]
# 或者: from django.db.models.query_utils import PathInfo [as 别名]
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
示例7: get_path_info
# 需要导入模块: from django.db.models import query_utils [as 别名]
# 或者: from django.db.models.query_utils import PathInfo [as 别名]
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,
)]
示例8: get_reverse_path_info
# 需要导入模块: from django.db.models import query_utils [as 别名]
# 或者: from django.db.models.query_utils import PathInfo [as 别名]
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,
)]
示例9: get_path_info
# 需要导入模块: from django.db.models import query_utils [as 别名]
# 或者: from django.db.models.query_utils import PathInfo [as 别名]
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)]
示例10: get_reverse_path_info
# 需要导入模块: from django.db.models import query_utils [as 别名]
# 或者: from django.db.models.query_utils import PathInfo [as 别名]
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
示例11: get_path_info
# 需要导入模块: from django.db.models import query_utils [as 别名]
# 或者: from django.db.models.query_utils import PathInfo [as 别名]
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)]
示例12: get_reverse_path_info
# 需要导入模块: from django.db.models import query_utils [as 别名]
# 或者: from django.db.models.query_utils import PathInfo [as 别名]
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)]
示例13: get_path_info
# 需要导入模块: from django.db.models import query_utils [as 别名]
# 或者: from django.db.models.query_utils import PathInfo [as 别名]
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,
)]
示例14: get_reverse_path_info
# 需要导入模块: from django.db.models import query_utils [as 别名]
# 或者: from django.db.models.query_utils import PathInfo [as 别名]
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,
)]