11from datetime import datetime
22
33import rest_framework
4-
54from packaging import version
5+
66from rest_framework_json_api import relations , serializers
77
88from example .models import (
2020
2121
2222class TaggedItemSerializer (serializers .ModelSerializer ):
23-
2423 class Meta :
2524 model = TaggedItem
26- fields = ('tag' , )
25+ fields = ('tag' ,)
2726
2827
2928class BlogSerializer (serializers .ModelSerializer ):
30-
3129 copyright = serializers .SerializerMethodField ()
3230 tags = TaggedItemSerializer (many = True , read_only = True )
3331
@@ -46,12 +44,11 @@ def get_root_meta(self, resource, many):
4644 class Meta :
4745 model = Blog
4846 fields = ('name' , 'url' , 'tags' )
49- read_only_fields = ('tags' , )
47+ read_only_fields = ('tags' ,)
5048 meta_fields = ('copyright' ,)
5149
5250
5351class EntrySerializer (serializers .ModelSerializer ):
54-
5552 def __init__ (self , * args , ** kwargs ):
5653 super (EntrySerializer , self ).__init__ (* args , ** kwargs )
5754 # to make testing more concise we'll only output the
@@ -97,15 +94,14 @@ class Meta:
9794 model = Entry
9895 fields = ('blog' , 'headline' , 'body_text' , 'pub_date' , 'mod_date' ,
9996 'authors' , 'comments' , 'featured' , 'suggested' , 'tags' )
100- read_only_fields = ('tags' , )
97+ read_only_fields = ('tags' ,)
10198 meta_fields = ('body_format' ,)
10299
103100 class JSONAPIMeta :
104101 included_resources = ['comments' ]
105102
106103
107104class AuthorBioSerializer (serializers .ModelSerializer ):
108-
109105 class Meta :
110106 model = AuthorBio
111107 fields = ('author' , 'body' )
0 commit comments