title: Django Rest Framework Pagination - Return last page by default
body: <p>I am working on a chats app using django rest framework to return a list of messages.</p>
  
  <p>These are my codes in api.py</p>
  
  <pre><code>class MessageList(generics.ListAPIView):
      queryset = Message.objects.all()
      serializer_class = MessageSerializer
      pagination_class = MessagePagination
  
      def get_queryset(self):
          queryset = super(MessageList, self).get_queryset()
          return queryset.filter(room__id=self.kwargs.get('pk')).order_by('id')
  </code></pre>
  
  <p>Using <a href="http://localhost:8000/chats/message-list/[room_pk]/?page=" rel="nofollow noreferrer">http://localhost:8000/chats/message-list/[room_pk]/?page=</a>?, I was able to get the list of messages I wanted in different pages. </p>
  
  <p>However, I would like the last page to be returned by default since I will also be implementing js infinite scrolling later on. In other words, by entering the url <a href="http://localhost:8000/chats/message-list/[room_pk]/" rel="nofollow noreferrer">http://localhost:8000/chats/message-list/[room_pk]/</a>, the last page objects will be return instead.</p>
  
  <p>I am pretty new in django rest framework so I really appreciate any help given. Thanks in advance.</p>