def all(cls):
    q = super(LatestMixin, cls).all()

def latest():
    if cls.ORDER_FIELD is None:
        raise ValueError('ORDER_FIELD must be defined')
return q.order('-' + cls.ORDER_FIELD).get()
q.latest = latest
return q


class Foo(LatestMixin, db.Model):
    ORDER_FIELD = 'timestamp'
timestamp = db.DateTimeProperty(auto_now_add=True)
latest = Foo.all().latest()
Equivalent of objects.latest() in App Engine