You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But how can i get the plant name instead of its Key
The text was updated successfully, but these errors were encountered:
get2abhi
changed the title
GET request output with Foreign Key Property(Name, etc.)
GET request response with Foreign Key Property(Name, etc.) instead of key
Mar 4, 2016
The issue here is that we need to recursively decode the referenced object (plant in your case), but that's not always what the user wants. It's also problematic in case we have an endless recursion (e.g. two models that point to each other).
So we have 3 possible solutions at the moment:
Use StructuredProperty (in your case, plant = ndb.StructuredProperty(Plant)). But that means that the Plant instance won't exist directly in the DB with its own key/ID (meaning, you won't be able to query for it directly).
Do a second API call with the returned key for Plant (call GET /api/plant/<returned_key>).
We implement in rest_gae recursive decoding of objects. However, we must make sure that - A) We won't do endless recursion of decoding models. B) We'll only decode models that have a specific flag turned on (e.g. using RESTMeta).
I have the following models
Now in the GET request for department is working fine and the output is
/api/department
But how can i get the plant name instead of its Key
The text was updated successfully, but these errors were encountered: