开发者

GAE - retrieving the last entry (python)

I am trying to get the most recent data item from the datastore. I am trying to apply the method as explained here but I am getting the object <__main__.Rep object at 0x075F1730> not the item. Can anyone explain what I am doing wrong?

The Model is:

class Rep(db.Model):
    sent = db.StringProperty()
    time = db.DateTimeProperty(auto_now_add=True)

This is the handler:

class Repeater(webapp.RequestHandler):
    def get(self):        
 开发者_如何学JAVA       reps = Rep()
        reps.sent = self.request.get('sentence')
        reps.put()

        s = self.request.get('sentence')             

        query = reps.all()
        last = query.order('-time').get()
        sentences = query

Thanks!


I don't see anything wrong at all.

<__main__.Rep object at 0x075F1730> is presumably an instance of your Rep class, as expected.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜