1👍
✅
There is regroup but that will still destroy your page loading times as more traffic arrives (irony?)
What would be better would be to implement pagination into your view and then order_by
whatever date it is you want, you could then start to think about search functionalities as required. To make this easier, django has a ListView which has support for pagination built in to it so there isn’t a lot of code to write
As a very quick example, this is pretty much the whole listview code you’d need
class MyListView(ListView):
model = Traffic
paginate_by = 25
template_name = 'foo.html'
def get_queryset(self):
return self.model.objects.order_by('created')
{% for traffic in object_list %}
{% endfor %}
Source:stackexchange.com