djangoappengine

Google App Engine NDB custom key id

别等时光非礼了梦想. 提交于 2019-11-30 17:05:26
When I create an object with ndb's method put it creates the key automatically of the type Key(kind, id) where id is a number. All over the documentation it shows that you can use a string for the key's id but I couldn't find out how to do this automatically when an object is created. I have a User model and I was thinking to use the user's username (since its unique) as the key's id for faster retrieval. Is that even a good idea? Would I have any problems with the username since it's user submited (i'm validating the input)? class UserModel(ndb.Model): ... user_model_entity = UserModel(id=

Google App Engine NDB custom key id

…衆ロ難τιáo~ 提交于 2019-11-30 01:08:41
问题 When I create an object with ndb's method put it creates the key automatically of the type Key(kind, id) where id is a number. All over the documentation it shows that you can use a string for the key's id but I couldn't find out how to do this automatically when an object is created. I have a User model and I was thinking to use the user's username (since its unique) as the key's id for faster retrieval. Is that even a good idea? Would I have any problems with the username since it's user

app engine datastore auto-clears every time project runs

让人想犯罪 __ 提交于 2019-11-27 08:25:02
问题 Every time I run my project (eith dev_appserver.py myapp or manage.py runserver in django), the datastore will be cleared. I have persisted the data by model.put() or model.save() in django. In the current session, I can see the data in the admin page, but next time I run the project, all previous datastore is lost. I know app engine has the --clear_datastore run condition, but i dont't want this feature. By the way, where is there a local datastore file? 回答1: you can use the --datastore_path