You need to check for the identifier in the model key in _pre_put_hook.
If you look at the source for the ndb model class, you will see that the key was actually created and assigned to the model instance before calling _pre_put_hook, but the key does not have an identifier. This code inside _pre_put_hook should work:
def _pre_put_hook(self): if self.key.id() is None: print 'model has not been saved' else: print 'model has been saved'
source share