title: Issues with django rest framework using dynamic serializer
body: <p>I'm have a dynamic dataset I am trying to use with the Django REST Framework by dynamically creating serializer, but it doesn't seem to process the dynamic attributes I add.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>-- views.py
  class DynamicReadings(generics.ListAPIView):
      def get_serializer_class(self):
          site = self.kwargs['site']
          devices = Device.objects.filter(reader__site__slug=site).order_by('code')
          dyn_fields = ['x%s' % a.code for a in devices]
          return SerializerClassFactory(dyn_fields)
  
      def get_queryset(self):
          ...
          # the query is correct and returns data
  
  -- serializers.py
  def SerializerClassFactory(dyn_fields):
  class DynamicSerializer(serializers.Serializer):
      read_at = serializers.DateTimeField()
  
      class Meta:
          fields = ('read_at')
  
      for f in dyn_fields:
          setattr(DynamicSerializer, f, serializers.FloatField())
      DynamicSerializer.Meta.fields += ','.join("'%s'" % f for f in dyn_fields)
  
      return DynamicSerializer
  </code></pre>
  
  <p>When I execute the code, only the attribute (read_at) specified in the class definition is serialized.  None of the dynamic attributes appear to be working.</p>
  
  <p>Example:</p>
  
  <p>[{"read_at":"2017-05-07T00:12:29Z"},{"read_at":"2017-05-08T00:12:30Z"}]</p>
  
  <p>Here is the output of the class after creation in shell:</p>
  
  <pre><code>&gt;&gt;&gt; serializer = SerializerClassFactory(['x01', 'x02', 'x03'])
  &gt;&gt;&gt; serializer.__dict__
  mappingproxy({'__module__': 'xxx.api.serializers', 
  'Meta': &lt;class 'xxx.api.serializers.SerializerClassFactory.&lt;locals&gt;.DynamicSerializer.Meta'&gt;, 
  'x02': FloatField(), '_declared_fields': OrderedDict([('read_at', DateTimeField())]), 
  '__doc__': None, 'x01': FloatField(), 'x03': FloatField()})
  </code></pre>
  
  <p>Additionally, I've tried:</p>
  
  <pre><code>setattr(DynamicSerializer, f, property(serializers.FloatField()))
  setattr(DynamicSerializer, f, type(serializers.FloatField()))
  </code></pre>
  
  <p>I'm not sure what I am doing wrong.</p>