diff --git a/django_filters/rest_framework/backends.py b/django_filters/rest_framework/backends.py index 1e74dd758..a837324cf 100644 --- a/django_filters/rest_framework/backends.py +++ b/django_filters/rest_framework/backends.py @@ -97,9 +97,8 @@ def get_schema_fields(self, view): return [] if not filter_class else [ compat.coreapi.Field( name=field_name, - required=field.required, + required=field.extra['required'], location='query', schema=self.get_coreschema_field(field) - ) - for field_name, field in filter_class.base_filters.items() + ) for field_name, field in filter_class.base_filters.items() ] diff --git a/tests/rest_framework/test_filters.py b/tests/rest_framework/test_filters.py index 872094e26..29fbb3245 100644 --- a/tests/rest_framework/test_filters.py +++ b/tests/rest_framework/test_filters.py @@ -12,4 +12,4 @@ def test_widget(self): # from `rest_framework.filters`. f = filters.BooleanFilter() - self.assertEqual(f.widget, BooleanWidget) + self.assertEqual(f.extra['widget'], BooleanWidget) diff --git a/tests/rest_framework/test_filterset.py b/tests/rest_framework/test_filterset.py index 815a2eaea..bc04ba981 100644 --- a/tests/rest_framework/test_filterset.py +++ b/tests/rest_framework/test_filterset.py @@ -29,7 +29,7 @@ def test_booleanfilter_widget(self): field = User._meta.get_field('is_active') result = FilterSet.filter_for_field(field, 'is_active') self.assertIsInstance(result, filters.BooleanFilter) - self.assertEqual(result.widget, BooleanWidget) + self.assertEqual(result.extra['widget'], BooleanWidget) @skipIf(is_crispy(), 'django_crispy_forms must be installed') diff --git a/tests/test_filtering.py b/tests/test_filtering.py index 36167130a..e4556844c 100644 --- a/tests/test_filtering.py +++ b/tests/test_filtering.py @@ -651,7 +651,7 @@ def __init__(self, *args, **kwargs): 'queryset': Book.objects.filter(id__in=[1, 2]) }) - self.filters['favorite_books'].required = True + self.filters['favorite_books'].extra['required'] = True qs = User.objects.all().order_by('username')