Skip to content

Instantly share code, notes, and snippets.

@hackedd
Created October 21, 2015 08:05
Show Gist options
  • Save hackedd/d97ca2f282b53c33f990 to your computer and use it in GitHub Desktop.
Save hackedd/d97ca2f282b53c33f990 to your computer and use it in GitHub Desktop.
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