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


Python filterset.FilterSet类代码示例

本文整理汇总了Python中django_filters.filterset.FilterSet的典型用法代码示例。如果您正苦于以下问题:Python FilterSet类的具体用法?Python FilterSet怎么用?Python FilterSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FilterSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_unknown_field_type_error

    def test_unknown_field_type_error(self):
        f = NetworkSetting._meta.get_field('mask')

        with self.assertRaises(AssertionError) as excinfo:
            FilterSet.filter_for_field(f, 'mask')

        self.assertIn(
            "FilterSet resolved field 'mask' with 'exact' lookup "
            "to an unrecognized field type SubnetMaskField",
            excinfo.exception.args[0])
开发者ID:carltongibson,项目名称:django-filter,代码行数:10,代码来源:test_filterset.py

示例2: test_filter_for_field_with_extras

 def test_filter_for_field_with_extras(self):
     f = User._meta.get_field('favorite_books')
     result = FilterSet.filter_for_field(f, 'favorite_books')
     self.assertIsInstance(result, ModelMultipleChoiceFilter)
     self.assertEqual(result.name, 'favorite_books')
     self.assertTrue('queryset' in result.extra)
     self.assertIsNotNone(result.extra['queryset'])
开发者ID:grengojbo,项目名称:django-filter,代码行数:7,代码来源:filterset_tests.py

示例3: test_field_with_choices

 def test_field_with_choices(self):
     f = User._meta.get_field("status")
     result = FilterSet.filter_for_field(f, "status")
     self.assertIsInstance(result, ChoiceFilter)
     self.assertEqual(result.name, "status")
     self.assertTrue("choices" in result.extra)
     self.assertIsNotNone(result.extra["choices"])
开发者ID:krimkus,项目名称:django-filter,代码行数:7,代码来源:test_filterset.py

示例4: test_reverse_m2m_field_with_through_model

 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,代码行数:8,代码来源:test_filterset.py

示例5: test_reverse_m2m_relationship

 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,代码行数:8,代码来源:test_filterset.py

示例6: test_reverse_o2o_relationship

 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,代码行数:8,代码来源:test_filterset.py

示例7: test_non_symmetrical_selfref_m2m_field

 def test_non_symmetrical_selfref_m2m_field(self):
     f = DirectedNode._meta.get_field("outbound_nodes")
     result = FilterSet.filter_for_field(f, "outbound_nodes")
     self.assertIsInstance(result, ModelMultipleChoiceFilter)
     self.assertEqual(result.name, "outbound_nodes")
     self.assertTrue("queryset" in result.extra)
     self.assertIsNotNone(result.extra["queryset"])
     self.assertEqual(result.extra["queryset"].model, DirectedNode)
开发者ID:krimkus,项目名称:django-filter,代码行数:8,代码来源:test_filterset.py

示例8: test_field_with_extras

 def test_field_with_extras(self):
     f = User._meta.get_field("favorite_books")
     result = FilterSet.filter_for_field(f, "favorite_books")
     self.assertIsInstance(result, ModelMultipleChoiceFilter)
     self.assertEqual(result.name, "favorite_books")
     self.assertTrue("queryset" in result.extra)
     self.assertIsNotNone(result.extra["queryset"])
     self.assertEqual(result.extra["queryset"].model, Book)
开发者ID:krimkus,项目名称:django-filter,代码行数:8,代码来源:test_filterset.py

示例9: test_filter_found_for_uuidfield

 def test_filter_found_for_uuidfield(self):
     if UUIDTestModel is None:
         self.assertLess(django.VERSION, (1, 8))
     else:
         f = UUIDTestModel._meta.get_field('uuid')
         result = FilterSet.filter_for_field(f, 'uuid')
         self.assertIsInstance(result, UUIDFilter)
         self.assertEqual(result.name, 'uuid')
开发者ID:Openergy,项目名称:django-filter,代码行数:8,代码来源:test_filterset.py

示例10: test_reverse_m2m_field_with_through_model

 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,代码行数:8,代码来源:test_filterset.py

示例11: test_reverse_fk_relationship

 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,代码行数:8,代码来源:test_filterset.py

示例12: test_reverse_m2m_relationship

 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,代码行数:8,代码来源:test_filterset.py

示例13: test_reverse_non_symmetrical_selfref_m2m_field

 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,代码行数:8,代码来源:test_filterset.py

示例14: test_symmetrical_selfref_m2m_field

 def test_symmetrical_selfref_m2m_field(self):
     f = Node._meta.get_field('adjacents')
     result = FilterSet.filter_for_field(f, 'adjacents')
     self.assertIsInstance(result, ModelMultipleChoiceFilter)
     self.assertEqual(result.name, 'adjacents')
     self.assertTrue('queryset' in result.extra)
     self.assertIsNotNone(result.extra['queryset'])
     self.assertEqual(result.extra['queryset'].model, Node)
开发者ID:dekoza,项目名称:django-filter,代码行数:8,代码来源:test_filterset.py

示例15: test_reverse_o2o_relationship

 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,代码行数:8,代码来源:test_filterset.py


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