class Article(models.Model):
title = models.CharField(max_length=200, default='')
prev = models.TextField(blank=True, max_length=200, default='')
text = models.TextField()
created_date = models.DateTimeField(default=timezone.now)
published_date = models.DateTimeField(blank=True, null=True)
def catalogue(request):
list_of_products = Product.objects.all()
page = request.GET.get('page', 1)
paginator = Paginator(list_of_products, 4)
try:
products = paginator.page(page)
except PageNotAnInteger:
products = paginator.page(1)
except EmptyPage:
products = paginator.page(paginator.num_pages)
return render(request, 'catalogue.html', {'products': products})
path('catalogue', views.catalogue)