6

based on this docs https://developers.google.com/appengine/docs/python/ndb/entities#deleting_entities well, im still not sure why i cannot do the delete on NDB:

def get(self):
  id = self.request.get("delete")
  ndb.Key('category', id).delete()

yeah i know how to select using id

ndb.Key('category', id).get()

but its still not working...

key = ndb.Key('category', id).get()
key.delete()

this one also not working:

category.key.delete()

something wrong?

alex
  • 479,566
  • 201
  • 878
  • 984
zho
  • 643
  • 1
  • 12
  • 27

1 Answers1

12

Try this:

ndb.Key(category, int(id)).delete()

You need to convert the id to integer in order to build a numeric (id) key instead of a name key.

Shay Erlichmen
  • 31,691
  • 7
  • 68
  • 87