title: DRF: static/read-only/non-model fields in serializers?
body: <p>Is it possible to include static fields in a model serializer? For example, I have a model:</p>
  
  <pre><code>class Location(models.Model):
      long = models.FloatField(...)
      lat = models.FloatField(...)
  </code></pre>
  
  <p>and a serializer: </p>
  
  <pre><code>class LocationSerialiser(serializers.ModelSerializer):
      class Meta:
          model = Location
          fields = ("id", "long", "lat")
  </code></pre>
  
  <p>with a simple <code>ListAPIView</code> I can see all my locations: </p>
  
  <pre><code>{
      'id': 1,
      'long': ...,
      'lat': ...,
  }, 
  ...
  </code></pre>
  
  <p>but say I want to have a static, non-model field added to all objects in my json response? Something like: </p>
  
  <pre><code>{
      'id': 1,
      'long': ...,
      'lat': ...,
      'display': True,
      'icon': 'image/marker.png'
  }, 
  ...
  </code></pre>
  
  <p>How can I add these to the serializer? I've looked through the <a href="https://github.com/tomchristie/django-rest-framework/blob/2.4.4/rest_framework/fields.py" rel="noreferrer"><code>fields</code></a> module (for 2.2.4) but I don't see any clear way of achieving this. Everything needs a <code>source</code> attribute. </p>
  
  <p>Ideally I would like to do </p>
  
  <pre><code>class LocationSerialiser(serializers.ModelSerializer):
      display = fields.BooleanField(value=True)
      icon = fields.CharField(value="image/marker.png")
  
      class Meta:
          model = Location
          fields = ("id", "long", "lat")
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>One approach I've found is to simply put extra <code>@property</code> wrapped methods on the model instance: </p>
  
  <pre><code>class Location(models.Model):
      long = models.FloatField(...)
      lat = models.FloatField(...)
  
      @property
      def show(self):
          return True
  
      ...
  </code></pre>
  
  <p>and then in the serializer: </p>
  
  <pre><code>class LocationSerialiser(serializers.ModelSerializer):
      display = fields.BooleanField(value=True)
      icon = fields.CharField(value="image/marker.png")
  
      show = fields.CharField(source="show")
  
      class Meta:
          model = Location
          fields = ("id", "long", "lat")
  </code></pre>
  
  <p>but this seems very hacky. There must be a cleaner way of achieving this? </p>