I want to order by only pagination result, for example in the first page I get two products (the meaning of this mehsul is a product) and when I get ordering I want to order these two products.
def animal(request,slug):
mehsul=Product.objects.filter(animal_type=slug)
animal_count=2
paginator=Paginator(mehsul,animal_count)
page_number=request.GET.get('page')
page_obj = paginator.get_page(page_number)
ordering = request.GET.get('ordering')
if ordering:
mehsul = Product.objects.filter(animal_type=slug)
paginator=Paginator(mehsul,animal_count)
page_number=request.GET.get('page')
page_obj=paginator.get_page(page_number)
return render(request,'animal.html',context={'mehsullar':page_obj})