本文整理汇总了Python中models.Issue.client方法的典型用法代码示例。如果您正苦于以下问题:Python Issue.client方法的具体用法?Python Issue.client怎么用?Python Issue.client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Issue
的用法示例。
在下文中一共展示了Issue.client方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_m2m_and_m2o
# 需要导入模块: from models import Issue [as 别名]
# 或者: from models.Issue import client [as 别名]
def test_m2m_and_m2o(self):
r = User.objects.create(username="russell")
g = User.objects.create(username="gustav")
i1 = Issue(num=1)
i1.client = r
i1.save()
i2 = Issue(num=2)
i2.client = r
i2.save()
i2.cc.add(r)
i3 = Issue(num=3)
i3.client = g
i3.save()
i3.cc.add(r)
self.assertQuerysetEqual(
Issue.objects.filter(client=r.id), [
1,
2,
],
lambda i: i.num
)
self.assertQuerysetEqual(
Issue.objects.filter(client=g.id), [
3,
],
lambda i: i.num
)
self.assertQuerysetEqual(
Issue.objects.filter(cc__id__exact=g.id), []
)
self.assertQuerysetEqual(
Issue.objects.filter(cc__id__exact=r.id), [
2,
3,
],
lambda i: i.num
)
# These queries combine results from the m2m and the m2o relationships.
# They're three ways of saying the same thing.
self.assertQuerysetEqual(
Issue.objects.filter(Q(cc__id__exact = r.id) | Q(client=r.id)), [
1,
2,
3,
],
lambda i: i.num
)
self.assertQuerysetEqual(
Issue.objects.filter(cc__id__exact=r.id) | Issue.objects.filter(client=r.id), [
1,
2,
3,
],
lambda i: i.num
)
self.assertQuerysetEqual(
Issue.objects.filter(Q(client=r.id) | Q(cc__id__exact=r.id)), [
1,
2,
3,
],
lambda i: i.num
)