Skip to content

Fix tests to work with DRF 3.6.3. #351

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
May 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Jerel Unruh <[email protected]>
Greg Aker <[email protected]>
Adam Wróbel <https://adamwrobel.com>
Christian Zosel <https://zosel.ch>
Greg Aker <[email protected]>
Jerel Unruh <[email protected]>
Matt Layman <http://www.mattlayman.com>
Oliver Sauder <[email protected]>

4 changes: 2 additions & 2 deletions example/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ class Meta:
class EntrySerializer(serializers.ModelSerializer):

def __init__(self, *args, **kwargs):
super(EntrySerializer, self).__init__(*args, **kwargs)
# to make testing more concise we'll only output the
# `featured` field when it's requested via `include`
request = kwargs.get('context', {}).get('request')
if request and 'featured' not in request.query_params.get('include', []):
self.fields.pop('featured')
super(EntrySerializer, self).__init__(*args, **kwargs)
self.fields.pop('featured', None)

included_serializers = {
'authors': 'example.serializers.AuthorSerializer',
Expand Down
3 changes: 1 addition & 2 deletions rest_framework_json_api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def to_internal_value(self, data):

class SparseFieldsetsMixin(object):
def __init__(self, *args, **kwargs):
super(SparseFieldsetsMixin, self).__init__(*args, **kwargs)
context = kwargs.get('context')
request = context.get('request') if context else None

Expand All @@ -74,8 +75,6 @@ def __init__(self, *args, **kwargs):
if field_name not in fieldset:
self.fields.pop(field_name)

super(SparseFieldsetsMixin, self).__init__(*args, **kwargs)


class IncludedResourcesValidationMixin(object):
def __init__(self, *args, **kwargs):
Expand Down