title: Django REST framework and creating two table entries from a POST form
body: <p>I want to create entries in two tables (Log and Post) using the DRF Browseable API POST form. </p>
  
  <p>The example below is contrived, but it outlines what I am trying to do.</p>
  
  <pre><code>class Post(models.Model):
      info = models.CharField()
  
  class Log(TimeStampedModel):
      ip = models.GenericIPAddressField(('IP Address'))
      name = models.CharField()
      data = models.ForeignKey(Post)                                       
  </code></pre>
  
  <p>I want to use the browseable API to submit a form to create a Log entry. Here are the serializers:</p>
  
  <pre><code>class PostSerializer(serializers.ModelSerializer):
      class Meta:
          model = Post
          fields = ('info',)
  
  class LogSerializer(serializers.ModelSerializer):                          
      data = serializers.Field()
  
      class Meta:
          model = Log
          fields = ('ip', 'name', 'data')
  </code></pre>
  
  <p>The problem with the above is that <code>serializer.Field</code> is read only so does not show up on the POST form. If I change it to CharField it shows up, but then I get an error because an instance of a Post is expected not just a field of the Post object.</p>
  
  <p>Here are my views:</p>
  
  <pre><code>class LogMixin(object):
      queryset = Log.objects.all()                                           
      serializer_class = LogSerializer
  
  
  
  class LogList(LogMixin, ListCreateAPIView):
      pass
  
  
  class LogDetail(LogMixin, RetrieveUpdateDestroyAPIView):
      pass
  </code></pre>
  
  <p>What's the correct way of doing this?</p>