Answers for "django model to get last entry"

1

how to get last values or data in django orm

my_queryset.reverse()[:5]
Posted by: Guest on September-14-2021
0

get last save id django model

latest_id = models.objects.latest('id').id
# check last id then do something with that then.
latest_id = Entry.objects.latest('id')

# source
https://docs.djangoproject.com/en/3.2/ref/models/querysets/#latest
Posted by: Guest on May-31-2021

Python Answers by Framework

Browse Popular Code Answers by Language