1from django.contrib.auth.models import User
2from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
3
4def index(request):
5 user_list = User.objects.all()
6 page = request.GET.get('page', 1)
7
8 paginator = Paginator(user_list, 10)
9 try:
10 users = paginator.page(page)
11 except PageNotAnInteger:
12 users = paginator.page(1)
13 except EmptyPage:
14 users = paginator.page(paginator.num_pages)
15
16 return render(request, 'core/user_list.html', { 'users': users })