{"action":"created","issue":{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2119","labels_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2119/labels{/name}","comments_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2119/comments","events_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2119/events","html_url":"https://github.com/tomchristie/django-rest-framework/pull/2119","id":49892089,"number":2119,"title":"Use `ReturnDict` and `ReturnList` for nested serializers","user":{"login":"g-cassie","id":4053345,"avatar_url":"https://avatars.githubusercontent.com/u/4053345?v=3","gravatar_id":"","url":"https://api.github.com/users/g-cassie","html_url":"https://github.com/g-cassie","followers_url":"https://api.github.com/users/g-cassie/followers","following_url":"https://api.github.com/users/g-cassie/following{/other_user}","gists_url":"https://api.github.com/users/g-cassie/gists{/gist_id}","starred_url":"https://api.github.com/users/g-cassie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/g-cassie/subscriptions","organizations_url":"https://api.github.com/users/g-cassie/orgs","repos_url":"https://api.github.com/users/g-cassie/repos","events_url":"https://api.github.com/users/g-cassie/events{/privacy}","received_events_url":"https://api.github.com/users/g-cassie/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/labels/Needs%20design%20decision","name":"Needs design decision","color":"c7def8"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2014-11-24T14:00:16Z","updated_at":"2015-07-01T15:36:33Z","closed_at":"2015-06-30T15:00:15Z","pull_request":{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/pulls/2119","html_url":"https://github.com/tomchristie/django-rest-framework/pull/2119","diff_url":"https://github.com/tomchristie/django-rest-framework/pull/2119.diff","patch_url":"https://github.com/tomchristie/django-rest-framework/pull/2119.patch"},"body":"This PR just contains some initial ideas for implementing this without moving the `ReturnDict`/`ReturnList` wrapping back into `.to_representation()`.  That said a lot of tests are failing and I'm not sure this is the right path so wanted to seek guidance from the community before going to far ahead on this.  \r\n\r\n## Explanation\r\n\r\nI am working on a set of plugins for DRF that will allow it to work out of the box with `Ember Data` (ED), a data persistence library that is commonly used with Ember.js.  ED accepts two forms of serialized data, one of which it refers to as the ActiveModel style serialization. \r\n\r\nActiveModelJson expects a JSON payload that looks like this:\r\n\r\n```\r\ndealerships: [\r\n    {\r\n        id: 1,\r\n        title: 'The Car Depot',\r\n        car_ids: [1, 2, 3, 4],\r\n    }\r\n    ...\r\n],\r\n```\r\n\r\nOr like this:\r\n\r\n```\r\ndealership: [\r\n   id: 1,\r\n   title: 'The Car Depot',\r\n   cars: [ {\r\n        id: 1,\r\n        title: 'Toyata',\r\n        dealership_id: 1,\r\n    },\r\n    ...\r\n   ]\r\n]\r\n```\r\n\r\nIn order to convert to this format in a DRF serializer, the renderer must be able to check whether a particular field is a model relation and if so change it from `plural_words` to `plural_word_ids` or from `singular_word` to `singular_word_id`.  Note that you cannot just check if the property contains an array or integer as that would result in converting integer fields and arbitrary lists by accident.\r\n\r\n[This code](https://github.com/g-cassie/ember-drf/blob/master/ember_drf/utils.py#L31-L74) worked until about a week ago when the `ReturnDict`/`ReturnList` wrapping was moved into the `.data` property.  Now that ReturnDict/Lists do not nest, I do not see any way of achieving the same behaviour using a renderer alone.  At the same time I think the changes I am trying to make are the kind of purely aesthetic changes which should be implemented in the Renderer.  \r\n\r\nThis is a big blocker for my project so anything I can do to move this along quickly would be greatly appreciated.\r\n"},"comment":{"url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/comments/117718416","html_url":"https://github.com/tomchristie/django-rest-framework/pull/2119#issuecomment-117718416","issue_url":"https://api.github.com/repos/tomchristie/django-rest-framework/issues/2119","id":117718416,"user":{"login":"g-cassie","id":4053345,"avatar_url":"https://avatars.githubusercontent.com/u/4053345?v=3","gravatar_id":"","url":"https://api.github.com/users/g-cassie","html_url":"https://github.com/g-cassie","followers_url":"https://api.github.com/users/g-cassie/followers","following_url":"https://api.github.com/users/g-cassie/following{/other_user}","gists_url":"https://api.github.com/users/g-cassie/gists{/gist_id}","starred_url":"https://api.github.com/users/g-cassie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/g-cassie/subscriptions","organizations_url":"https://api.github.com/users/g-cassie/orgs","repos_url":"https://api.github.com/users/g-cassie/repos","events_url":"https://api.github.com/users/g-cassie/events{/privacy}","received_events_url":"https://api.github.com/users/g-cassie/received_events","type":"User","site_admin":false},"created_at":"2015-07-01T15:36:32Z","updated_at":"2015-07-01T15:36:32Z","body":"@thedrow We found away around it and are getting by.  As it turns out Ember-Data is now moving over to JSON-api so the adapter for Ember I maintain will become less relevant."}}