本文整理汇总了Python中django_filters.filterset.FilterSet.filter_for_reverse_field方法的典型用法代码示例。如果您正苦于以下问题:Python FilterSet.filter_for_reverse_field方法的具体用法?Python FilterSet.filter_for_reverse_field怎么用?Python FilterSet.filter_for_reverse_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django_filters.filterset.FilterSet
的用法示例。
在下文中一共展示了FilterSet.filter_for_reverse_field方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_reverse_non_symmetrical_selfref_m2m_field
# 需要导入模块: from django_filters.filterset import FilterSet [as 别名]
# 或者: from django_filters.filterset.FilterSet import filter_for_reverse_field [as 别名]
def test_reverse_non_symmetrical_selfref_m2m_field(self):
f = DirectedNode._meta.get_field_by_name('inbound_nodes')[0]
result = FilterSet.filter_for_reverse_field(f, 'inbound_nodes')
self.assertIsInstance(result, ModelMultipleChoiceFilter)
self.assertEqual(result.name, 'inbound_nodes')
self.assertTrue('queryset' in result.extra)
self.assertIsNotNone(result.extra['queryset'])
self.assertEqual(result.extra['queryset'].model, DirectedNode)
示例2: test_reverse_m2m_field_with_through_model
# 需要导入模块: from django_filters.filterset import FilterSet [as 别名]
# 或者: from django_filters.filterset.FilterSet import filter_for_reverse_field [as 别名]
def test_reverse_m2m_field_with_through_model(self):
f = Worker._meta.get_field_by_name('employers')[0]
result = FilterSet.filter_for_reverse_field(f, 'employers')
self.assertIsInstance(result, ModelMultipleChoiceFilter)
self.assertEqual(result.name, 'employers')
self.assertTrue('queryset' in result.extra)
self.assertIsNotNone(result.extra['queryset'])
self.assertEqual(result.extra['queryset'].model, Business)
示例3: test_reverse_o2o_relationship
# 需要导入模块: from django_filters.filterset import FilterSet [as 别名]
# 或者: from django_filters.filterset.FilterSet import filter_for_reverse_field [as 别名]
def test_reverse_o2o_relationship(self):
f = Account._meta.get_field_by_name('profile')[0]
result = FilterSet.filter_for_reverse_field(f, 'profile')
self.assertIsInstance(result, ModelChoiceFilter)
self.assertEqual(result.name, 'profile')
self.assertTrue('queryset' in result.extra)
self.assertIsNotNone(result.extra['queryset'])
self.assertEqual(result.extra['queryset'].model, Profile)
示例4: test_reverse_m2m_relationship
# 需要导入模块: from django_filters.filterset import FilterSet [as 别名]
# 或者: from django_filters.filterset.FilterSet import filter_for_reverse_field [as 别名]
def test_reverse_m2m_relationship(self):
f = Book._meta.get_field_by_name('lovers')[0]
result = FilterSet.filter_for_reverse_field(f, 'lovers')
self.assertIsInstance(result, ModelMultipleChoiceFilter)
self.assertEqual(result.name, 'lovers')
self.assertTrue('queryset' in result.extra)
self.assertIsNotNone(result.extra['queryset'])
self.assertEqual(result.extra['queryset'].model, User)
示例5: test_reverse_m2m_field_with_through_model
# 需要导入模块: from django_filters.filterset import FilterSet [as 别名]
# 或者: from django_filters.filterset.FilterSet import filter_for_reverse_field [as 别名]
def test_reverse_m2m_field_with_through_model(self):
f = Worker._meta.get_field("employers")
result = FilterSet.filter_for_reverse_field(f, "employers")
self.assertIsInstance(result, ModelMultipleChoiceFilter)
self.assertEqual(result.name, "employers")
self.assertTrue("queryset" in result.extra)
self.assertIsNotNone(result.extra["queryset"])
self.assertEqual(result.extra["queryset"].model, Business)
示例6: test_reverse_m2m_relationship
# 需要导入模块: from django_filters.filterset import FilterSet [as 别名]
# 或者: from django_filters.filterset.FilterSet import filter_for_reverse_field [as 别名]
def test_reverse_m2m_relationship(self):
f = Book._meta.get_field("lovers")
result = FilterSet.filter_for_reverse_field(f, "lovers")
self.assertIsInstance(result, ModelMultipleChoiceFilter)
self.assertEqual(result.name, "lovers")
self.assertTrue("queryset" in result.extra)
self.assertIsNotNone(result.extra["queryset"])
self.assertEqual(result.extra["queryset"].model, User)
示例7: test_reverse_o2o_relationship
# 需要导入模块: from django_filters.filterset import FilterSet [as 别名]
# 或者: from django_filters.filterset.FilterSet import filter_for_reverse_field [as 别名]
def test_reverse_o2o_relationship(self):
f = Account._meta.get_field("profile")
result = FilterSet.filter_for_reverse_field(f, "profile")
self.assertIsInstance(result, ModelChoiceFilter)
self.assertEqual(result.name, "profile")
self.assertTrue("queryset" in result.extra)
self.assertIsNotNone(result.extra["queryset"])
self.assertEqual(result.extra["queryset"].model, Profile)
示例8: test_reverse_fk_relationship
# 需要导入模块: from django_filters.filterset import FilterSet [as 别名]
# 或者: from django_filters.filterset.FilterSet import filter_for_reverse_field [as 别名]
def test_reverse_fk_relationship(self):
f = User._meta.get_field('comments')
result = FilterSet.filter_for_reverse_field(f, 'comments')
self.assertIsInstance(result, ModelMultipleChoiceFilter)
self.assertEqual(result.name, 'comments')
self.assertTrue('queryset' in result.extra)
self.assertIsNotNone(result.extra['queryset'])
self.assertEqual(result.extra['queryset'].model, Comment)
示例9: test_reverse_fk_relationship
# 需要导入模块: from django_filters.filterset import FilterSet [as 别名]
# 或者: from django_filters.filterset.FilterSet import filter_for_reverse_field [as 别名]
def test_reverse_fk_relationship(self):
f = User._meta.get_field_by_name("comments")[0]
result = FilterSet.filter_for_reverse_field(f, "comments")
self.assertIsInstance(result, ModelMultipleChoiceFilter)
self.assertEqual(result.name, "comments")
self.assertTrue("queryset" in result.extra)
self.assertIsNotNone(result.extra["queryset"])
self.assertEqual(result.extra["queryset"].model, Comment)