Skip to content

speed up matching of filter fields by using a set #9684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/api-guide/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ using the `APIView` class-based views.

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

from rest_framework.authentication import SessionAuthentication, BasicAuthentication
from rest_framework.decorators import api_view, authentication_classes, permission_classes
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response

@api_view(['GET'])
@authentication_classes([SessionAuthentication, BasicAuthentication])
@permission_classes([IsAuthenticated])
Expand Down
2 changes: 1 addition & 1 deletion rest_framework/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def get_valid_fields(self, queryset, view, context={}):
return valid_fields

def remove_invalid_fields(self, queryset, fields, view, request):
valid_fields = [item[0] for item in self.get_valid_fields(queryset, view, {'request': request})]
valid_fields = {item[0] for item in self.get_valid_fields(queryset, view, {'request': request})}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add/update tests to verify this


def term_valid(term):
if term.startswith("-"):
Expand Down
Loading