You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fair enough. I'll put some code up tomorrow or the day after. In the meantime, the most basic example, without code, would be this: There is a model Person with a CharField name. There is a a view that is subclassed off of generics.ListAPIView. This view's get_queryset method is overridden to return people whose name contains a search by a user encoded in a parameter q passed in a get request (i.e. Person.objects.all().filter(Q(name__icontains=self.request.query_params['q']))).
This view is wired up to a url and instantiated with as_view(). Unfortunately, if Cursor Pagination is active (or others, possibly, I have not tested), then the next link will not include the query parameter q. It will only include a parameter for the cursor. This will result in a "400: Bad Request" because there is no query parameter for the search. I don't know if this is a known issue or not. I've already worked around it on my end.
If none of the above is clear, no worries, I'll drop some code to clarify ASAP. Thank you for your work on a truly fantastic product! I have subclassed, used, and read the code repeatedly this past year, for a variety of products. It truly is a life-saver.
Thanks! That should be enough to get started with.
I still don't quite see where/why that'd result in a 400 (I'd expect a KeyError to be raised by your get_queryset() method, instead) but either way the upshot is that CursorPagination should preserve any other query parameters present in the request.
The url in next doesn't include the query parameters used in a request, causing 400 bad request responses when using cursor pagination.
The text was updated successfully, but these errors were encountered: