Skip to content

Commit b2bddc5

Browse files
committed
speed up matching of filter fields by using a set
1 parent ea1da76 commit b2bddc5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

docs/api-guide/authentication.md

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ using the `APIView` class-based views.
6767

6868
Or, if you're using the `@api_view` decorator with function based views.
6969

70+
from rest_framework.authentication import SessionAuthentication, BasicAuthentication
71+
from rest_framework.decorators import api_view, authentication_classes, permission_classes
72+
from rest_framework.permissions import IsAuthenticated
73+
from rest_framework.response import Response
74+
7075
@api_view(['GET'])
7176
@authentication_classes([SessionAuthentication, BasicAuthentication])
7277
@permission_classes([IsAuthenticated])

rest_framework/filters.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def get_valid_fields(self, queryset, view, context={}):
311311
return valid_fields
312312

313313
def remove_invalid_fields(self, queryset, fields, view, request):
314-
valid_fields = [item[0] for item in self.get_valid_fields(queryset, view, {'request': request})]
314+
valid_fields = {item[0] for item in self.get_valid_fields(queryset, view, {'request': request})}
315315

316316
def term_valid(term):
317317
if term.startswith("-"):

0 commit comments

Comments
 (0)