File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -15,14 +15,22 @@ def fields(self):
1515 """
1616 Filters the fields according to the `fields` query parameter.
1717
18- a blank `fields` parameter (?fields) will remove all fields.
19- not passing `fields` will pass all fields
20- individual fields are comma separated (?fields=id,name,url,email)
18+ A blank `fields` parameter (?fields) will remove all fields. Not
19+ passing `fields` will pass all fields individual fields are comma
20+ separated (?fields=id,name,url,email).
21+
2122 """
2223 fields = super (DynamicFieldsMixin , self ).fields
2324
2425 if not hasattr (self , '_context' ):
25- # we are being called before a request cycle.
26+ # We are being called before a request cycle
27+ return fields
28+
29+ # Only filter if this is the root serializer, or if the parent is the
30+ # root serializer with many=True
31+ is_root = self .root == self
32+ parent_is_list_root = self .parent == self .root and getattr (self .parent , 'many' , False )
33+ if not (is_root or parent_is_list_root ):
2634 return fields
2735
2836 try :
You can’t perform that action at this time.
0 commit comments