Answer the question
In order to leave comments, you need to log in
How to get the last element as fast as possible in Django?
Hello everyone
There is a model of about 1000 records, new elements are constantly added to the tail. The task is to get the id-number of the last element as quickly as possible.
test = Test.objects.all().order_by('-id')[0].id
test = Test.objects.all().last().id
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question