Skip to content

Commit

Permalink
Fix complex filtering + pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan P Kilby committed Dec 23, 2017
1 parent 59f0839 commit fbeb181
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rest_framework_filters/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from django.http import QueryDict
from django_filters.rest_framework import backends
from rest_framework.exceptions import ValidationError
from rest_framework.request import clone_request

from .complex_ops import decode_querystring_ops, OPERATORS
from .filterset import FilterSet
Expand Down Expand Up @@ -47,6 +46,7 @@ class ComplexFilterBackend(DjangoFilterBackend):

def filter_queryset(self, request, original, view):
parent = super(ComplexFilterBackend, self)
original_GET = request._request.GET

if self.complex_filter_param not in request.query_params:
return parent.filter_queryset(request, original, view)
Expand All @@ -61,10 +61,10 @@ def filter_queryset(self, request, original, view):
queryset_op = OPERATORS['&'] # effectively a noop

for querystring, op in querystring_ops:
cloned = clone_request(request, request.method)
cloned._request.GET = QueryDict(querystring)
request._request.GET = QueryDict(querystring)

queryset = queryset_op(queryset, parent.filter_queryset(cloned, original, view))
queryset = queryset_op(queryset, parent.filter_queryset(request, original, view))
queryset_op = OPERATORS.get(op)

request._request.GET = original_GET
return queryset

0 comments on commit fbeb181

Please sign in to comment.