Suppose I have a view:
class FooPagination(PageNumberPagination):
page_size = 10
class FooView(ListAPIView):
serializer_class = FooSerializer
pagination_class = FooPagination
def get_queryset(self):
print(self.?) # page number?
In get_queryset is it possible to extract the current page number from the request URL in Django REST? For example, as in the following URL:
http://127.0.0.1:8000/foo/?page=10
答案 0 :(得分:3)
try:
pagenum = self.request.query_params.get('page', None)