title: How to use PrimaryKeyRelatedField to update categories on a many-to-many relationship
body: <p>The Django Rest Framework has a <a href="http://www.django-rest-framework.org/api-guide/relations/#primarykeyrelatedfield" rel="nofollow">PrimaryKeyRelatedField</a> which lists ID's on my <code>many-to-many</code> relationship with categories...</p>
  
  <pre><code>class CatalogueItemsSerializer(serializers.HyperlinkedModelSerializer):
      url = serializers.HyperlinkedIdentityField(view_name='catalogue_item_detail')
      name = serializers.CharField(min_length=2, max_length=60)
      categories = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
  </code></pre>
  
  <p>I would like to override the <code>create()</code> get a lot of posted ID's (traditionally DRF wants me to send URL's) on the categories field.</p>
  
  <p>JSON POST: </p>
  
  <pre><code>{
  "name": "test",
  "categories": [1,2]
  }
  </code></pre>
  
  <p>Serializer Create:</p>
  
  <pre><code>def create(self, validated_data):
      categories = validated_data.pop('categories', None)
      print(categories) # This shows and empty/None even when ID are posted!
  </code></pre>
  
  <p>The issue I have is <code>categories</code> will be empty above, I assume because <code>PrimaryKeyRelatedField</code> is set to <code>read_only=True</code> but this <strong>HAS</strong> to be true on according to DRF. </p>
  
  <p>My question is... How to use <code>PrimaryKeyRelatedField</code> with <code>validated_data.pop</code> to get a list of ID's I submitted? </p>
  
  <p>I could use <code>self.context.get("request").data['categories']</code> but this is nasty and requires me to turn it into a list + other stuff.  </p>