Reputation: 1070
I need to get the row id of each row so that I can use it as primary key. This is what I'm doing
qr = MoreGames.query()
res = qr.fetch()
if res:
data = []
for row in res:
d = {'id':row.key().id(),'title':row.title,'description':row.description,'link':row.link}
data.append(d);
Whenever I use row.key().id() it gives me '500 internal server error'.
Upvotes: 1
Views: 557
Reputation: 10360
Using .query()
suggests you're using NDB rather than DB, in which case 'key
' is a property rather than a method, so:
row.key.id()
to get the id-part of the key.
Upvotes: 4
Reputation: 15143
Try debugging.
Most likely your key has a name instead of an id. Try id_or_name() instead of id().
Upvotes: 0