django-piston: how to add an entity field to manyToMany related entity fields ?

I have two Entities: Post and Tag, with a ManyToMany relation called 'tagged' What I need to do, in order to parse json returned on particular client, is output fields by adding a field 'postID' (the pk field of current Post) to Tag related to that post. So, my output now is: { "post": { "name": "Dummy name", "pk": 1, "tags": [ { "id": 2, "name": "Patio" }, { "id": 3, "name": "Roof" } ], "ref": "709230056" } }, but it should be: { "post": { "name": "Dummy name", "pk": 1, "tags": [ { "id": 2, "name": "Patio", "postID": 1, }, { "id": 3, "name": "Roof" "postID": 1, } ], "ref": "709230056" } }, I've alrady tried to play with fields of my Handler but with no success :( How to do that ? Thanks
Why would you do that? You already have the id of the current post. Although, Post and Tags have a many to many relationship.. do you mean that you want to return all of the post id's for each tag?

以上就是django-piston: how to add an entity field to manyToMany related entity fields ?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JSON 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏