Zeynel
Zeynel

Reputation: 13525

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):        
        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!

Upvotes: 1

Views: 716

Answers (1)

Drew Sears
Drew Sears

Reputation: 12838

I don't see anything wrong at all.

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

Upvotes: 3

Related Questions