File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
netbox/netbox/api/viewsets Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -56,8 +56,15 @@ def get_serializer_class(self):
5656 def get_queryset (self ):
5757 qs = super ().get_queryset ()
5858
59- # If using brief mode, clear all prefetches from the queryset and append only brief_prefetch_fields (if any)
6059 if self .brief :
60+ serializer_class = self .get_serializer_class ()
61+
62+ # Clear any annotations for fields not present on the nested serializer
63+ for annotation in list (qs .query .annotations .keys ()):
64+ if annotation not in serializer_class ().fields :
65+ qs .query .annotations .pop (annotation )
66+
67+ # Clear any prefetches from the queryset and append only brief_prefetch_fields (if any)
6168 return qs .prefetch_related (None ).prefetch_related (* self .brief_prefetch_fields )
6269
6370 return qs
You can’t perform that action at this time.
0 commit comments