[Answer]-Show last three entries before a specific one

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]

Leave a comment