title: Rest Call gives error : Incorrect type. Expected pk value, received str
body: <p>This post has an update below. </p>
  
  <p>I currently have these two models. I am trying to create a job using <code>CreateAPIView</code>. Before I show the view here are my models</p>
  
  <pre><code>class modelJobCategory(models.Model):
      description = models.CharField(max_length=200, unique=True)
      other = models.CharField(max_length=200, unique=False , blank=True , null=True)
  
  
  class modelJob(models.Model):
      category            = models.ManyToManyField(modelJobCategory,null=True,default=None,blank=True)
      description         = models.CharField(max_length=200, unique=False)
  </code></pre>
  
  <p>These two are my serializers</p>
  
  <pre><code>class Serializer_CreateJobCategory(ModelSerializer):
      class Meta:
          model = modelJobCategory
          fields = [
              'description',
          ]
  
  class Serializer_CreateJob(ModelSerializer):
      class Meta:
          model = modelJob
          category = Serializer_CreateJobCategory
          fields = [
              'category',
              'description',
          ]
  
      def create(self, validated_data):
          job = modelJob.objects.create(user=user,category=?,...) #How to get category ?
          return job
  </code></pre>
  
  <p>Now this is my view</p>
  
  <pre><code>class CreateJob_CreateAPIView(CreateAPIView):
      serializer_class = Serializer_CreateJob
      queryset = modelJob.objects.all()
  
      def post(self, request, format=None):
          serializer = Serializer_CreateJob(data=request.data)
          if serializer.is_valid():
              serializer.save()
              return Response(serializer.data, status=status.HTTP_201_CREATED)
          return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
  </code></pre>
  
  <p>Now I am passing the following JSON</p>
  
  <pre><code>{
  "category" :{   
               "description": "Foo"   
              },
  "description" : "World"
  }
  </code></pre>
  
  <p>However I get the exception </p>
  
  <pre><code>{
    "category": [
      "Incorrect type. Expected pk value, received str."
    ]
  }
  </code></pre>
  
  <p>I came across the same question <a href="https://stackoverflow.com/questions/30764437/django-incorrect-type-expected-pk-value-received-str-error">here</a> and it mentions i need to define a slug field which I am not sure where. Any suggestion on how I can fix this ?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>So my create Job serializer looks like this now however it returns back the error</p>
  
  <blockquote>
    <p>Got AttributeError when attempting to get a value for field <code>category</code>
    on serializer <code>Serializer_CreateJob</code>. The serializer field might be
    named incorrectly and not match any attribute or key on the <code>modelJob</code>
    instance. Original exception text was: 'ManyRelatedManager' object has
    no attribute 'description'.</p>
  </blockquote>
  
  <pre><code>class Serializer_CreateJob(ModelSerializer):
      category = serializers.CharField(source='category.description')
      class Meta:
          model = modelJob
          category = Serializer_CreateJobCategory()
          fields = [
              'category',
              'description',
          ]
  
     def create(self, validated_data):
          category_data = validated_data.pop('category')
          category = modelJobCategory.objects.get(description=category_data['description'])
          job = modelJob.objects.create(description=validated_data["description"])
          job.category.add(category)
          job.save()
          return job
  </code></pre>
  
  <p>Any suggestions on how I can fix this now ?</p>