Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
jerel merged 2 commits into django-json-api:develop from tbartelmess:fix/include-in-many-related-serializer
Aug 18, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add a test for including many objects from a related serializer
  • Loading branch information
tbartelmess committed Jul 17, 2016
commit 184ab5fd4acfbb2ca4a0147f683da7ac717ec946
1 change: 1 addition & 0 deletions example/serializers.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, *args, **kwargs):
'authors': 'example.serializers.AuthorSerializer',
'comments': 'example.serializers.CommentSerializer',
'featured': 'example.serializers.EntrySerializer',
'suggested': 'example.serializers.EntrySerializer',
}

body_format = serializers.SerializerMethodField()
Expand Down
9 changes: 9 additions & 0 deletions example/tests/integration/test_includes.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ def test_dynamic_related_data_is_included(single_entry, entry_factory, client):
assert len(included) == 1, 'The dynamically included blog entries are of an incorrect count'


def test_dynamic_many_related_data_is_included(single_entry, entry_factory, client):
entry_factory()
response = client.get(reverse("entry-detail", kwargs={'pk': single_entry.pk}) + '?include=suggested')
included = load_json(response.content).get('included')

assert included
assert [x.get('type') for x in included] == ['entries'], 'Dynamic included types are incorrect'


def test_missing_field_not_included(author_bio_factory, author_factory, client):
# First author does not have a bio
author = author_factory(bio=None)
Expand Down

AltStyle によって変換されたページ (->オリジナル) /