1
I think you need to reverse the sort order, so that youβre ordering by reverse start time.
Also, Iβm not sure what your exclude is supposed to be doing. You want to get things that are less than the current item, so it seems more sensible to remove that exclude and just use __lt
rather than __lte
.
former_entries = Entry.objects.all().filter(start__lt=entry.start, customer=customer).order_by('-start')[:3]
Source:stackexchange.com