How can I retrieve the last record in a certain queryset?
latest(field_name=None)
returns the latest object in the table, by date, using the field_name provided as the date field.This example returns the latest Entry in the table, according to the
pub_date
field:Entry.objects.latest('pub_date')