title: DRF convert datetime to timestamp in response
body: <p>My model contains a datetime field, I want to convert it to timestamp when requested. Here is the <code>get</code> handler for the response:</p>
  
  <pre><code>def get(self, request, pk):
      journal = Journal.objects.get(pk=pk)
      serializer = LogSerializer(journal)
      return Response(serializer.data)
  </code></pre>
  
  <p>Here is the response:</p>
  
  <pre><code>{
    ...blah...
    "created": "2015-12-02T08:57:16.881528Z",
  }
  </code></pre>
  
  <p>I tried this to get the unix timestamp:</p>
  
  <pre><code>from django.utils.dateformat import format
  
  def get(self, request, pk):
      journal = Journal.objects.get(pk=pk)
      journal.created = format(journal.created, 'U') #error, because the LogSerializer expects a datetime object instead of a string
      serializer = LogSerializer(journal)
      return Response(serializer.data)
  </code></pre>
  
  <p>Here is my serializer and model:</p>
  
  <pre><code>class LogSerializer(ModelSerializer):
      class Meta:
          model = Journal
  
  
  class Journal(Model):
      created = models.DateTimeField(auto_now_add=True)
  </code></pre>
  
  <p>Is there a way to tell the JSONRender to do the following:</p>
  
  <pre><code>if fieldName == 'created': 
      data['created'] = convert_to_timestamp(data['created'])
  </code></pre>
  
  <p>or Should I just modify the stringified data:</p>
  
  <pre><code>content = JSONRender(serializer.data)
  ... find the position of the time string in content and replace it with the timestamp ...
  </code></pre>