Created
October 21, 2015 08:05
-
-
Save hackedd/d97ca2f282b53c33f990 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.filters import BaseFilterBackend | |
class BulkFilter(BaseFilterBackend): | |
def filter_queryset(self, request, queryset, view): | |
if request.method in ("PUT", "PATCH") and isinstance(request.DATA, list): | |
ids = [obj.get("id") for obj in request.DATA] | |
queryset = queryset.filter(pk__in=ids) | |
return queryset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment