django query get last n records #Python #Django #queryset
django query get last n records last_ten = Messages.objects.filter(since=since).order_by('-id')[:10] # You can pass your queryset to reversed: last_ten_in_ascending_order = reversed(last_ten) # Or use [::-1] instead of reversed last_ten = Messages.objects.filter(since=since).order_by('-id')[:10][::-1]
2019.11.13