#NEWLINE# def paginate_queryset( self , queryset , request , view = None ) : #NEWLINE# #INDENT# '\n        Paginate a queryset if required, either returning a\n        page object, or `None` if pagination is not configured for this view.\n        ' #NEWLINE# page_size = self . get_page_size ( request ) #NEWLINE# if ( not page_size ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# paginator = PaginatorWithoutCount ( queryset , page_size ) #NEWLINE# page_number = request . query_params . get ( self . page_query_param , 1 ) #NEWLINE# if ( page_number in self . last_page_strings ) : #NEWLINE# #INDENT# page_number = paginator . num_pages #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# self . page = paginator . page ( page_number ) #NEWLINE# #UNINDENT# except InvalidPage as exc : #NEWLINE# #INDENT# msg = self . invalid_page_message . format ( page_number = page_number , message = six . text_type ( exc ) ) #NEWLINE# raise NotFound ( msg ) #NEWLINE# #UNINDENT# if ( ( paginator . num_pages > 1 ) and ( self . template is not None ) ) : #NEWLINE# #INDENT# self . display_page_controls = True #NEWLINE# #UNINDENT# self . request = request #NEWLINE# return list ( self . page )