I'm trying to develop a website, where I wrote a function based view, and now want to add pagination.I'm following the django documentation, but it's just not coming together. Can anyone help me please? my views.py:
from django.shortcuts import render, Http404
from django.http import HttpResponse
from .models import Product
from django.core.paginator import Paginator
def home(request):
products = Product.objects.all()
paginator = Paginator(products, 6)
page_number = request.GET.get('page')
page_obj = paginator.get_page(page_number)
return render(request, 'index.html', {'products': products})