1
1
from datetime import datetime
2
2
3
3
import rest_framework
4
-
5
4
from packaging import version
5
+
6
6
from rest_framework_json_api import relations , serializers
7
7
8
8
from example .models import (
20
20
21
21
22
22
class TaggedItemSerializer (serializers .ModelSerializer ):
23
-
24
23
class Meta :
25
24
model = TaggedItem
26
- fields = ('tag' , )
25
+ fields = ('tag' ,)
27
26
28
27
29
28
class BlogSerializer (serializers .ModelSerializer ):
30
-
31
29
copyright = serializers .SerializerMethodField ()
32
30
tags = TaggedItemSerializer (many = True , read_only = True )
33
31
@@ -46,12 +44,11 @@ def get_root_meta(self, resource, many):
46
44
class Meta :
47
45
model = Blog
48
46
fields = ('name' , 'url' , 'tags' )
49
- read_only_fields = ('tags' , )
47
+ read_only_fields = ('tags' ,)
50
48
meta_fields = ('copyright' ,)
51
49
52
50
53
51
class EntrySerializer (serializers .ModelSerializer ):
54
-
55
52
def __init__ (self , * args , ** kwargs ):
56
53
super (EntrySerializer , self ).__init__ (* args , ** kwargs )
57
54
# to make testing more concise we'll only output the
@@ -97,15 +94,14 @@ class Meta:
97
94
model = Entry
98
95
fields = ('blog' , 'headline' , 'body_text' , 'pub_date' , 'mod_date' ,
99
96
'authors' , 'comments' , 'featured' , 'suggested' , 'tags' )
100
- read_only_fields = ('tags' , )
97
+ read_only_fields = ('tags' ,)
101
98
meta_fields = ('body_format' ,)
102
99
103
100
class JSONAPIMeta :
104
101
included_resources = ['comments' ]
105
102
106
103
107
104
class AuthorBioSerializer (serializers .ModelSerializer ):
108
-
109
105
class Meta :
110
106
model = AuthorBio
111
107
fields = ('author' , 'body' )
0 commit comments