{"action":"created","issue":{"url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api/issues/74","labels_url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api/issues/74/labels{/name}","comments_url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api/issues/74/comments","events_url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api/issues/74/events","html_url":"https://github.com/django-json-api/django-rest-framework-json-api/issues/74","id":105656190,"number":74,"title":"Serializer `resource_name` for nested objects is not used","user":{"login":"mkohram","id":5775304,"avatar_url":"https://avatars.githubusercontent.com/u/5775304?v=3","gravatar_id":"","url":"https://api.github.com/users/mkohram","html_url":"https://github.com/mkohram","followers_url":"https://api.github.com/users/mkohram/followers","following_url":"https://api.github.com/users/mkohram/following{/other_user}","gists_url":"https://api.github.com/users/mkohram/gists{/gist_id}","starred_url":"https://api.github.com/users/mkohram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkohram/subscriptions","organizations_url":"https://api.github.com/users/mkohram/orgs","repos_url":"https://api.github.com/users/mkohram/repos","events_url":"https://api.github.com/users/mkohram/events{/privacy}","received_events_url":"https://api.github.com/users/mkohram/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-09-09T18:32:34Z","updated_at":"2015-10-19T22:44:25Z","closed_at":null,"body":"Nested serializers don't use `resource_name` for the `type`. In the example below the `type` for the child would show something like `nestedmodels`.\r\n```python\r\nclass NestedSerializer(serializers.ModelSerializer):\r\n    resource_name = \"pretty_nested\"\r\n    class Meta:\r\n        model = NestedModel\r\n\r\nclass ParentSerializer(serializers.ModelSerializer):\r\n    nested = NestedSerializer(source='some_field', many=True)\r\n    class Meta:\r\n        model = ParentModel\r\n```\r\n\r\nLooking at the code it looks like in `utils.py` the only function that performs the correct checks to get the `type` is `get_resource_name()`. All the other functions simply do something like `relation_type = inflection.pluralize(relation_model.__name__).lower()` without checking for a `resource_name` on the serializer as the docs suggest. I could submit a PR if it makes sense to put these checks in place everywhere. Ideally a function like `get_related_resource_type()` should act as a getter for `type` so that we don't see these inconsistencies."},"comment":{"url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api/issues/comments/149368750","html_url":"https://github.com/django-json-api/django-rest-framework-json-api/issues/74#issuecomment-149368750","issue_url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api/issues/74","id":149368750,"user":{"login":"mkohram","id":5775304,"avatar_url":"https://avatars.githubusercontent.com/u/5775304?v=3","gravatar_id":"","url":"https://api.github.com/users/mkohram","html_url":"https://github.com/mkohram","followers_url":"https://api.github.com/users/mkohram/followers","following_url":"https://api.github.com/users/mkohram/following{/other_user}","gists_url":"https://api.github.com/users/mkohram/gists{/gist_id}","starred_url":"https://api.github.com/users/mkohram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkohram/subscriptions","organizations_url":"https://api.github.com/users/mkohram/orgs","repos_url":"https://api.github.com/users/mkohram/repos","events_url":"https://api.github.com/users/mkohram/events{/privacy}","received_events_url":"https://api.github.com/users/mkohram/received_events","type":"User","site_admin":false},"created_at":"2015-10-19T22:44:25Z","updated_at":"2015-10-19T22:44:25Z","body":"OK. One more ...\r\n\r\nIf the field is defined as `ResourceRelatedField` then [this line](https://github.com/django-json-api/django-rest-framework-json-api/blob/73bc6d57a1321ec4d831e2a78a1b09d1d6573308/rest_framework_json_api/relations.py#L121) returns the wrong `type` in the data. The `type` is correct in the `included` section though. Stumbled on this one on accident.\r\nI'm generally getting terrified of `format_relation_name(get_resource_type_from_instance(instance))`. I searched the repo and found it in a couple more places too ([here](https://github.com/django-json-api/django-rest-framework-json-api/blob/73bc6d57a1321ec4d831e2a78a1b09d1d6573308/rest_framework_json_api/views.py#L157) and [here](https://github.com/django-json-api/django-rest-framework-json-api/blob/73bc6d57a1321ec4d831e2a78a1b09d1d6573308/rest_framework_json_api/serializers.py#L27)). Not sure if they are harmful or not, would put my bets on yes :smirk:."}}