title: django rest framework nested objects get or create behaviour
body: <p>I am creating an api end point using django-rest-framework for a specific json input. I have two related models like so (let's assume post can only have one category):</p>
  
  <pre><code>class Category(models.Model):
      name = models.CharField(max_length=10)
      slug = models.SlugField()
  
  
  class Post(models.Model):
      category = models.ForeignKey()
      title = models.CharField(max_length=100)
      text = models.CharField(max_length=256)
  </code></pre>
  
  <p>and my serializer are simple model serializers:</p>
  
  <pre><code>class CategorySerializer(ModelSerializer):
      id = serializers.IntegerField(required=True)
  
      class Meta:
          model = Category
  
  
  class PostSerializer(ModelSerializer):
      id = serializers.IntegerField(required=True)
      category = CategorySerializer()
  
      class Meta:
          model = Post
  </code></pre>
  
  <p>and my api view is very simple also:</p>
  
  <pre><code>class PostAPIView(mixins.CreateModelMixin, GenericAPIView):
      serializer_class = PostSerializer
      permission_classes = (IsAuthenticated,)
  </code></pre>
  
  <p>now in order to create posts I need to parse a json input like this:</p>
  
  <pre><code>{
      "id": 10,
      "pk": 10
      "title": "Some title",
      "text": "Some text",
      "category": {
          "id": 15,
          "pk": 15
          "name": "Best category",
          "slug": "best-category"
      }
  }
  </code></pre>
  
  <p>in here 'pk' parameters are crucial for me, I want data to be created on my db using exact pk provided in json. Now if I make a post request and there are no posts with id:10 and categories with id:15 all is fine and data is written to db new records get inserted, but if there are any when rest-framework returns an error like ['Post id 10 already exists'], I would like matching records to be updated according to input instead. How can I do that?</p>