How to get max value in django ORM
latest
returns the latest object in the table according to the added
date:
AuthorizedEmail.objects.filter(group=group).latest('added')
From the documentation:
>>> from django.db.models import Max
>>> AuthorizedEmail.objects.aggregate(Max('added'))
And to fetch the value in the template:
{{ item.added__max }}