Problem with db.get in Google App Engine
When I run the following code:
query = datastore.Food_Item.all()
results = query.fetch(1)
foodA = results[0]
foodB = db.get(foodA.key())
I would expect foodA and foodB to be the same type. However, I see that the foodA is of type "model.datastore.Food_Item" and foodB is of type "datastore.Food_Item". Why are they different?
FYI, the Food_Item model is defined in datastore.py, which is found in the "model" directory. I'm new to app engine, so any feedback you could provide would be 开发者_如何学JAVAgreatly appreciated. Thanks!
It seems likely you're importing the same module (model.datastore) by different names in different places - for example, by using a relative import inside the model package. db.get returns whichever name it saw when the module was first imported, while your own code (the query) returns whatever you explicitly specified.
精彩评论