title: GenericForeignKey, ContentType and DjangoRestFramework
body: <p>I am working on an discussion app in Django, that has Threads, Posts, Replies and Votes.  Votes uses <a href="https://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/">Generic Foreign Keys and Content Types</a> to ensure a user can only vote once on a specific Thread/Post/Reply.</p>
  
  <p>Vote model looks like this:</p>
  
  <pre><code>VOTE_TYPE = (
      (-1, 'DISLIKE'),
      (1, 'LIKE'),
  )
  
  class Vote(models.Model):
      user = models.ForeignKey(User)
      content_type = models.ForeignKey(ContentType,
          limit_choices_to={"model__in": ("Thread", "Reply", "Post")}, 
          related_name="votes")
      object_id = models.PositiveIntegerField()
      content_object = generic.GenericForeignKey('content_type', 'object_id')
      vote = models.IntegerField(choices=VOTE_TYPE)
  
      objects = GetOrNoneManager()
  
      class Meta():
          unique_together = [('object_id', 'content_type', 'user')]
  </code></pre>
  
  <p>Vote Serializer:</p>
  
  <pre><code>class VoteSerializer(serializers.ModelSerializer):
      class Meta:
          model = Vote
  </code></pre>
  
  <p>The view to handle a vote:</p>
  
  <pre><code>@api_view(['POST'])
  def discussions_vote(request):
  
  if not request.user.is_authenticated():
      return Response(status=status.HTTP_404_NOT_FOUND)
  
  data = request.DATA
  
  if data['obj_type'] == 'thread':
      content_type = ContentType.objects.get_for_model(Thread)
  
      print content_type.id
  
      info = {
          'content_type': content_type.id,
          'user': request.user.id,
          'object_id': data['obj']['id']
      }
  
      vote = Vote.objects.get_or_none(**info)
  
      info['vote'] = data['vote']
  
      ser = VoteSerializer(vote, data=info)
  
      if ser.is_valid():
          print "Valid"
      else:
          pprint.pprint(ser.errors)
  
  return Response()
  </code></pre>
  
  <p>request.DATA content:</p>
  
  <pre><code>{u'vote': -1, 
  u'obj_type': u'thread', 
  u'obj': 
      {
      ...
      u'id': 7, 
      ...
      }
  }
  </code></pre>
  
  <p>When I vote, Django Rest Framework serializer throws an error:</p>
  
  <pre><code>Model content type with pk 149 does not exist.  
  </code></pre>
  
  <p>149 is the correct id for the ContentType for the Thread model, according to </p>
  
  <pre><code>print content_type.id
  </code></pre>
  
  <p>I'm pretty much at a loss at what could be causing this...</p>