def _list_groups(request, template, query, context={}):
 sort_form = forms.SortForm(request.GET)
 show_pagination = False
 if sort_form.is_valid():
  query = query.order_by(sort_form.cleaned_data['sort'], 'name')
 else:
  query = query.order_by('name')
 paginator = Paginator(query, settings.ITEMS_PER_PAGE)
 page = request.GET.get('page', 1)
 try:
  groups = paginator.page(page)
 except PageNotAnInteger:
  groups = paginator.page(1)
 except EmptyPage:
  groups = paginator.page(paginator.num_pages)
 if (paginator.count > settings.ITEMS_PER_PAGE):
  show_pagination = True
 data = {'groups': groups, 'page': page, 'sort_form': sort_form, 'show_pagination': show_pagination}
 data.update(context)
 return render(request, template, data)

def _list_groups ( request , template , query , context = { } ) : sort_form = forms . SortForm ( request . GET ) show_pagination = False if sort_form . is_valid ( ) : query = query . order_by ( sort_form . cleaned_data [ 'sort' ] , 'name' ) else : query = query . order_by ( 'name' ) paginator = Paginator ( query , settings . ITEMS_PER_PAGE ) page = request . GET . get ( 'page' , 1 ) try : groups = paginator . page ( page ) except PageNotAnInteger : groups = paginator . page ( 1 ) except EmptyPage : groups = paginator . page ( paginator . num_pages ) if ( paginator . count > settings . ITEMS_PER_PAGE ) : show_pagination = True data = { 'groups' : groups , 'page' : page , 'sort_form' : sort_form , 'show_pagination' : show_pagination } data . update ( context ) return render ( request , template , data )
lists groups from given query .