code: def serialize_queryset(self, queryset):
          
          object_data = []
          is_queryset = False
          query_fields = self.get_fields()
          try:
              iter(queryset)
              is_queryset = True
              raw_data = serializers.serialize(self.serializer_name, queryset, fields=query_fields,
                                               use_natural_keys=self.serialize_natural_keys)
          except TypeError:  # Not iterable
              raw_data = serializers.serialize(self.serializer_name, [queryset, ], fields=query_fields,
                                               use_natural_keys=self.serialize_natural_keys)
  
          for obj in raw_data:  # Add pk to fields
              obj['fields']['pk'] = obj['pk']
              object_data.append(obj['fields'])
  
          if is_queryset:
              return object_data
          return object_data[0]
docs: Return serialized queryset or single object as python dictionary
          serialize() only works on iterables, so to serialize a single object we put it in a list