What would be the best way to get the latest inserted object using AppEngine ?
I know in Django this can be done using
MyObject.objects.latest()
in AppEngine I’d like to be able to do this
class MyObject(db.Model):
time = db.DateTimeProperty(auto_now_add=True)
# Return latest entry from MyObject.
MyObject.all().latest()
Any idea ?
Your best bet will be to implement a
latest()classmethod directly onMyObjectand call it likeAnything else would require monkeypatching the built-in
Queryclass.Update
I thought I’d see how ugly it would be to implement this functionality. Here’s a mixin class you can use if you really want to be able to call
MyObject.all().latest():