def author_listing_view(request): template_name = "author/author_listing.html" context = {} authors = Author.get_all() paginator = Paginator(authors, 10) page = request.GET.get('page', 1) try: context["authors"] = paginator.page(page) except PageNotAnInteger: context["authors"] = paginator.page(1) except EmptyPage: context["authors"] = paginator.page(paginator.num_pages) context["page"] = page context["page_title"] = "Authors" return render(request, template_name, context)
def get_all_authors(request): context = {'author_list': list(Author.get_all()), 'books': Book.get_all()} return render(request, 'author/author_list.html', context)
def test_get_all(self): """ Positive Test of the CustomUser.create method TEST_DATE_END""" authors = list(Author.get_all()) authors.sort(key=lambda author: author.id) self.assertListEqual(authors, [self.author1, self.author2])