Skip to content

SerializerMethodResourceRelatedField with many=True does not show up in included #260

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

Merged
merged 2 commits into from
Aug 18, 2016
Merged

SerializerMethodResourceRelatedField with many=True does not show up in included #260

merged 2 commits into from
Aug 18, 2016

Conversation

tbartelmess
Copy link
Contributor

When using a SerializerMethodResourceRelatedField in a serializer, with many=True being set, and the request is asking for to include it (via the ?include) parameter, the field is not included in the result.

This PR adds a test and a fairly hackish fix (by checking is a 'child_relation' is present in the _kwargs parameter, when the field is evaluated for includes).

@tbartelmess
Copy link
Contributor Author

It looks like only one building Travis failed. It looks like the setup failed
The command "curl -s -o python-3.5.tar.bz2 ${archive_url}" failed and exited with 18 during .
not an actual test

@khornberg
Copy link

Would it be helpful if this was behind a setting so that those with accustomed to the current behavior are not affected? Or is this a bug? I am preferable to the former.

khornberg added a commit to imtapps-dev/django-rest-framework-json-api that referenced this pull request Aug 18, 2016
Adds PR 260
django-json-api#260

This allows a resource related field to be returned with the request
instead of having to make multiple requests to get related fields.
@jerel jerel added this to the 2.1.0 milestone Aug 18, 2016
@jerel
Copy link
Member

jerel commented Aug 18, 2016

I would view this as a bug: when a field is specified in include it should be included.

jerel added a commit that referenced this pull request Aug 18, 2016
@khornberg
Copy link

Yeah, after playing with it, I came to the same conclusion.

@jerel jerel merged commit c1049e4 into django-json-api:develop Aug 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants