2017-10-25 django django pagination demo 1. a demo for using pagination 1234567891011121314151617from django.core.paginator import Paginator, EmptyPage, PageNotAnIntegerdef listing(request): contact_list = Contacts.objects.all() paginator = Paginator(contact_list, 25) # Show 25 contacts per page page = request.GET.get('page') try: contacts = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. contacts = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. contacts = paginator.page(paginator.num_pages) return render_to_response('list.html', {"contacts": contacts}) django_182 2. get objects length 12cnt = contact_list.count()cnt = Contacts.objects.all().count() Newer django redis cache delete pattern Older django delete multi object