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?

1 Answer 1

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.

2
  • Just curious, doesn't ndb allow us to have string ids? Is not related to the question perhaps, and this already solved his problem.
    – 0xc0de
    Sep 5, 2013 at 4:31
  • @0xc0de of course, if you want to control the id you need to pass a string Sep 5, 2013 at 8:28

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.