-
Notifications
You must be signed in to change notification settings - Fork 301
Include only a link in the relationships object #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello @arielpontes, have you managed to remove the |
Hello ! if the community thinks it's a good improvement, I will have some time to work on this in the next month. Let me know if there are any first thoughts/ideas.
All the best. |
There is a |
@sliverc I didn't find a way I can use @arielpontes I've made a PR that skips the "data", I think that is what you need to get your point 3. Hope that helps you |
@Anton-Shutik I guess a patch would need to be created then where data is not included when using Marking this as a bug then. |
@sliverc first of all, thank you so much for fast responses :) Agree, up to a point. But DRF's |
Valid point. When looking at your PR I just have a feeling using Potentially implementing a json api specific I have only looked briefly into it so I am not sure but I think it is properly good to investigate as it might be the more elegant solution without potential side effects for users of |
@sliverc I agree that having two fields is better than having a big one :) But it is not the case, I think. Since I've tried to create My changes does not affect I'm opened to other approaches to implement "data" skipping, but for now I use my fork and if you're ok with merging my PR I can add some tests and docs. |
Let's move our discussion into the PR as our discussion somehow moved into implementation details, but I think the issue here is clear how the end result should look like. |
According to the JSONAPI specification, if I have an
Article
model with a to-many relationship to aComment
model and I want to express this when I retrieve anArticle
resource, there are multiple valid ways I can do this:relationships
object and a list with the actual resource objects in theincluded
object.relationships
object only, without including the actual attributes of the comments./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.
The text was updated successfully, but these errors were encountered: