当前位置: 首页>>代码示例>>Python>>正文


Python FilterSet.filter_for_reverse_field方法代码示例

本文整理汇总了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)
开发者ID:dekoza,项目名称:django-filter,代码行数:10,代码来源:test_filterset.py

示例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)
开发者ID:dekoza,项目名称:django-filter,代码行数:10,代码来源:test_filterset.py

示例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)
开发者ID:dekoza,项目名称:django-filter,代码行数:10,代码来源:test_filterset.py

示例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)
开发者ID:dekoza,项目名称:django-filter,代码行数:10,代码来源:test_filterset.py

示例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)
开发者ID:krimkus,项目名称:django-filter,代码行数:10,代码来源:test_filterset.py

示例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)
开发者ID:krimkus,项目名称:django-filter,代码行数:10,代码来源:test_filterset.py

示例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)
开发者ID:krimkus,项目名称:django-filter,代码行数:10,代码来源:test_filterset.py

示例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)
开发者ID:Elec,项目名称:django-filter,代码行数:10,代码来源:test_filterset.py

示例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)
开发者ID:sanmugamk,项目名称:django-filter,代码行数:10,代码来源:test_filterset.py


注:本文中的django_filters.filterset.FilterSet.filter_for_reverse_field方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。