Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 37c5ae6

Browse files
committed
Fix tests among different environments
1 parent ae759e5 commit 37c5ae6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

example/serializers.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
from datetime import datetime
2+
from packaging import version
3+
4+
import rest_framework
25
from rest_framework_json_api import serializers, relations
36
from example.models import (
47
Blog, Entry, Author, AuthorBio, Comment, TaggedItem, Project, ArtProject, ResearchProject,
@@ -40,12 +43,12 @@ class Meta:
4043
class EntrySerializer(serializers.ModelSerializer):
4144

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

5053
included_serializers = {
5154
'authors': 'example.serializers.AuthorSerializer',
@@ -153,4 +156,5 @@ class CompanySerializer(serializers.ModelSerializer):
153156

154157
class Meta:
155158
model = Company
156-
fields = '__all__'
159+
if version.parse(rest_framework.VERSION) >= version.parse('3.3'):
160+
fields = '__all__'

0 commit comments

Comments
 (0)