<s> from django . conf import settings <EOL> from django . core . exceptions import PermissionDenied <EOL> from django . core . paginator import Paginator , InvalidPage <EOL> from django . http import Http404 <EOL> def paginate ( request , queryset , results_per_page = <NUM_LIT:20> ) : <EOL> paginator = Paginator ( queryset , results_per_page ) <EOL> try : <EOL> page = paginator . page ( int ( request . GET . get ( '<STR_LIT>' , <NUM_LIT:1> ) ) ) <EOL> except InvalidPage : <EOL> raise Http404 ( "<STR_LIT>" ) <EOL> except ValueError : <EOL> raise PermissionDenied ( ) <EOL> return page , paginator </s>
