{"action":"created","issue":{"url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api/issues/173","labels_url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api/issues/173/labels{/name}","comments_url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api/issues/173/comments","events_url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api/issues/173/events","html_url":"https://github.com/django-json-api/django-rest-framework-json-api/issues/173","id":122053002,"number":173,"title":"Creating object with relation","user":{"login":"riklaunim","id":1822699,"avatar_url":"https://avatars.githubusercontent.com/u/1822699?v=3","gravatar_id":"","url":"https://api.github.com/users/riklaunim","html_url":"https://github.com/riklaunim","followers_url":"https://api.github.com/users/riklaunim/followers","following_url":"https://api.github.com/users/riklaunim/following{/other_user}","gists_url":"https://api.github.com/users/riklaunim/gists{/gist_id}","starred_url":"https://api.github.com/users/riklaunim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/riklaunim/subscriptions","organizations_url":"https://api.github.com/users/riklaunim/orgs","repos_url":"https://api.github.com/users/riklaunim/repos","events_url":"https://api.github.com/users/riklaunim/events{/privacy}","received_events_url":"https://api.github.com/users/riklaunim/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-12-14T14:26:59Z","updated_at":"2015-12-17T14:06:48Z","closed_at":null,"body":"I'm having problem with making ember create request to work with DRF + DRF-json-api#0ceeddd9eaf02d60be7b5ea0574a4ce2623a3e8b when the created model has a relation ChildModel -> FK(Place).\r\n\r\nEmber posts the Place ID:\r\n\r\n    {'starts_at': '2015-12-14', 'id': None, 'ends_at': '2016-01-14', 'title': 'test', 'contents': 'test'\r\n    , 'place': OrderedDict([('id', '92'), ('type', 'places')]), 'language': 'pl', 'is_active': False}\r\n\r\nAnd DRF serializer class for the Child model API has:\r\n\r\n    place = serializers.HyperlinkedRelatedField(many=False, view_name='api:places-detail', read_only=True)\r\n\r\nYet it can't create child because place_id ends up null when trying to INSERT it.\r\n\r\nI can override create method in the API view and fetch place from that JSON data and set place/place_id values on request.data but that doesn't help either - like if something was overriding or ignoring my data.\r\n\r\nIs there a special create/update/delete configuration for DRF-json-api APIs? "},"comment":{"url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api/issues/comments/165460916","html_url":"https://github.com/django-json-api/django-rest-framework-json-api/issues/173#issuecomment-165460916","issue_url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api/issues/173","id":165460916,"user":{"login":"riklaunim","id":1822699,"avatar_url":"https://avatars.githubusercontent.com/u/1822699?v=3","gravatar_id":"","url":"https://api.github.com/users/riklaunim","html_url":"https://github.com/riklaunim","followers_url":"https://api.github.com/users/riklaunim/followers","following_url":"https://api.github.com/users/riklaunim/following{/other_user}","gists_url":"https://api.github.com/users/riklaunim/gists{/gist_id}","starred_url":"https://api.github.com/users/riklaunim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/riklaunim/subscriptions","organizations_url":"https://api.github.com/users/riklaunim/orgs","repos_url":"https://api.github.com/users/riklaunim/repos","events_url":"https://api.github.com/users/riklaunim/events{/privacy}","received_events_url":"https://api.github.com/users/riklaunim/received_events","type":"User","site_admin":false},"created_at":"2015-12-17T14:06:48Z","updated_at":"2015-12-17T14:06:48Z","body":"I've narrowed down the problem. In serializer I tried to use:\r\n```\r\nplace = PrimaryKeyRelatedField(many=False, queryset=Place.objects.all())\r\n```\r\nAnd that throw good error that instead of ID it got an OrderDict (when calling to_internal_value). So by subclassing that field to:\r\n\r\n```\r\nclass PrimaryKeyRelatedField(serializers.PrimaryKeyRelatedField):\r\n    def to_internal_value(self, data):\r\n        return self.get_queryset().get(pk=data['id'])\r\n```\r\nIt did work. So the actual problem is that the dict from relationship wasn't recognized as valid field value."}}