Skip to content

GET request response with Foreign Key Property(Name, etc.) instead of key #28

@get2abhi

Description

@get2abhi

I have the following models

class Plant(ndb.Model):
    name = ndb.StringProperty()
    company = ndb.KeyProperty(kind='Company')
    owner = ndb.KeyProperty(kind='User')
    class RESTMeta:
        user_owner_property = 'owner'
        include_output_properties = ['name']

class Department(ndb.Model):
    name = ndb.StringProperty()
    plant = ndb.KeyProperty(kind='Plant')
    owner = ndb.KeyProperty(kind='User')
    class RESTMeta:
        user_owner_property = 'owner'
        include_output_properties = ['name']

Now in the GET request for department is working fine and the output is

/api/department

{
  "next_results_url": null,
  "results": [
    {
      "owner": null,
      "plant": "aghzfnBnLWFwaXISCxIFUGxhbnQYgICAgIDyiAkM",
      "name": "Packing",
      "id": "aghzfnBnLWFwaXIXCxIKRGVwYXJ0bWVudBiAgICAmc6UCQw"
    }
  ]
}

But how can i get the plant name instead of its Key

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions