mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-04-15 06:32:11 +03:00
speed up matching of filter fields by using a set
This commit is contained in:
parent
ea1da76196
commit
b2bddc5a74
|
@ -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])
|
||||
|
|
|
@ -311,7 +311,7 @@ class OrderingFilter(BaseFilterBackend):
|
|||
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})}
|
||||
|
||||
def term_valid(term):
|
||||
if term.startswith("-"):
|
||||
|
|
Loading…
Reference in New Issue
Block a user