title: Django rest framework foreign key constraint fails creating model
body: <p>I have the following in a Django Rest Framework setup:</p>
  
  <p><strong>models.py:</strong></p>
  
  <pre><code>class Sku(BaseModel):
      sku_code = models.CharField(max_length=18, primary_key=True)
      supplier_id = models.PositiveIntegerField(db_index=True)
      soh = models.PositiveIntegerField(default=0)
      reserved = models.PositiveIntegerField(default=0)
      broken = models.PositiveIntegerField(default=0)
      unallocated = models.PositiveIntegerField(default=0)
      reorder = models.PositiveIntegerField(default=0)
  
  class Reservation(BaseModel):
      sku = models.ForeignKey(Sku, db_column='sku_code')
      order_id = models.PositiveIntegerField(db_index=True)
  </code></pre>
  
  <p><strong>serializers.py:</strong></p>
  
  <pre><code>class SkuSerializer(serializers.ModelSerializer):
      class Meta:
          model = Sku
          fields = (
              'sku_code',
              'supplier_id',
              'soh',
              'reserved',
              'broken',
              'unallocated',
              'reorder',
              'created_at',
              'modified_at',
          )
  
  
  class ReservationSerializer(serializers.ModelSerializer):
      sku = SkuSerializer(read_only=True)
  
      class Meta:
          model = Reservation
          fields = (
              'id',
              'order_id',
              'sku',
              'created_at',
              'modified_at'
          )
  </code></pre>
  
  <p><strong>views.py:</strong></p>
  
  <pre><code>class ReservationList(mixins.CreateModelMixin,
                        generics.GenericAPIView):
  
      queryset = Reservation.objects.all()
      serializer_class = ReservationSerializer
  
      def post(self, request, *args, **kwargs):
          sku = get_object_or_404(Sku, sku_code=request.data['sku_code'])
          request.data['sku'] = sku
          return self.create(request, *args, **kwargs)
  </code></pre>
  
  <p>Now when I post to the url linked to ReservationList.post view above I get the error: <code>IntegrityError: (1048, "Column 'sku_code' cannot be null")</code>.</p>
  
  <p>It seems to be bypassing the serializers validation and failing on the database layer. For some reason it doesn't accept the SKU being passed in. </p>
  
  <p>What am I doing wrong here? I have tried to follow the example at <a href="http://www.django-rest-framework.org/api-guide/relations/#nested-relationships" rel="nofollow">http://www.django-rest-framework.org/api-guide/relations/#nested-relationships</a> but this seems to break down with the <code>CreateModelMixin</code>. I can't tell if there is something wrong with how my models or serializers are set up.</p>