| in blog | Django on Fundor333 |
|---|---|
| original entry | Django List View With Show More |
Sometime you want to have infinite scrolling in a Django ListView. And there are good post about this topic on the internet like this one but nothing about infinite scrolling with filters.
In this tutorial I assume you have a Product django model and a class view like this:
from django.db import model
class Product(models.Model):
title = models.CharField(max_length=250)
description = models.TextField()
def __str__(self):
return self.titlefrom django.views.generic.list import ListView
class ProductsView(ListView):
model = Product
paginate_by = 2
context_object_name = 'products'
template_name = 'product.html'
ordering = ['title']Following the post by thepylot this is a template for the list view: