<s> from django . core . paginator import ( Paginator , EmptyPage , PageNotAnInteger ) <EOL> from django . conf import settings <EOL> def paginate_data ( request , data , per_page = settings . PER_PAGE ) : <EOL> paginator = Paginator ( data , per_page ) <EOL> page = request . GET . get ( '<STR_LIT>' ) <EOL> try : <EOL> data = paginator . page ( page ) <EOL> except PageNotAnInteger : <EOL> data = paginator . page ( <NUM_LIT:1> ) <EOL> except EmptyPage : <EOL> data = paginator . page ( paginator . num_pages ) <EOL> return data </s>
