def _latest_date ( self , query , datetime_field_name ) : return list ( query . aggregate ( django . db . models . Max ( datetime_field_name ) ) . values ( ) ) [ 0 ]
get largest date from a list python
Given a QuerySet and the name of field containing datetimes return the latest ( most recent ) date .
def _latest_date(self, query, datetime_field_name):
        """Given a QuerySet and the name of field containing datetimes, return the
        latest (most recent) date.

        Return None if QuerySet is empty.

        """
        return list(
            query.aggregate(django.db.models.Max(datetime_field_name)).values()
        )[0]