def get_context_loop_positions(context):
 try:
  loop_counter = context['forloop']['counter']
 except KeyError:
  return (0, 0)
 try:
  page = context['page_obj']
 except KeyError:
  return (loop_counter, loop_counter)
 total_loop_counter = (((page.number - 1) * page.paginator.per_page) + loop_counter)
 return (total_loop_counter, loop_counter)

def get_context_loop_positions ( context ) : try : loop_counter = context [ 'forloop' ] [ 'counter' ] except KeyError : return ( 0 , 0 ) try : page = context [ 'page_obj' ] except KeyError : return ( loop_counter , loop_counter ) total_loop_counter = ( ( ( page . number - 1 ) * page . paginator . per_page ) + loop_counter ) return ( total_loop_counter , loop_counter )
return the paginated current position within a loop .