Closed
Description
According to the JSONAPI specification, if I have an Article
model with a to-many relationship to a Comment
model and I want to express this when I retrieve an Article
resource, there are multiple valid ways I can do this:
- Include the comments by default in the response, having a list of resource identifier objects in the
relationships
object and a list with the actual resource objects in theincluded
object. - Return a list of resource identifier objects in the
relationships
object only, without including the actual attributes of the comments. - Include only a link (e.g.
/articles/1/comments
) in therelationships
object.
I have a model that links to a lot of related objects so the 3rd option would be the best for me, but I can't configure the ResourceRelatedField to act like that. It always returns a data
object with the full list of related resource identifiers. Is there a way I can avoid this? Or do I have to extend the class myself? Doesn't seem very trivial to do that in a clean way.
Ideally, since the JSONAPI specs accept these 3 options, I think this library should allow these 3 configurations out of the box.