views:

46

answers:

1

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 greatly appreciated. Thanks!

+3  A: 

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.

Nick Johnson
Thanks Nick. You're correct, that was my issue. Thanks for your help.
Ryan