title: django bulk remove and add many to many relationships
body: <p>Im having a problem with bulk many to many relationship removing and adding.</p>
  
  <p>This is the JS that sends the pk of the user to be updated and the pk of the skills that will be added to the many to many.</p>
  
  <pre><code>function attachskillls(){
  
  var checkedValues = $('input:checkbox:checked').map(function() {
    return this.value;
  }).get();
  
  console.log(checkedValues)
  
  data = {
    'skills' : checkedValues,
    'pk' : getUrlVars()["id"]
  }
  console.log(data)
  
  $.ajax({
    type: "POST",
    url: "/api/skill/attch/",
    data: JSON.stringify(data),
    contentType: "application/json",
    dataType: "json"
  })
  </code></pre>
  
  <p>data is packed like this</p>
  
  <pre><code>{"skills":["1","2","3"],"pk":"1"}
  </code></pre>
  
  <p>This is the model the skills will be related to</p>
  
  <pre><code>class Resource(models.Model):
  
      title = models.CharField(max_length=10)
      preferred_name = models.CharField(max_length=20)
      last_name = models.CharField(max_length=30)
      employstatus = models.CharField(max_length=20)
      employer = models.ForeignKey('Employer')
      role = models.ForeignKey('Role')
      location = models.ForeignKey('Location')
      workphone = models.CharField(max_length=25, blank=True, null=True)
      mobile_phone = models.CharField(max_length=15, blank=True, null=True)
      email = models.CharField(max_length=15, blank=True, null=True)
      notes = models.CharField(max_length=200, blank=True, null=True)
      updated_by = models.CharField(max_length=30, blank=True, null=True)
      skillset = models.ManyToManyField('ReferenceSkillList')
  </code></pre>
  
  <p>This is my api so far I am trying to filter resource by pk so I have the correct user to add the skills to then to clear all relationships that may already be added then to bulk add the new relationships.  </p>
  
  <pre><code>def Skillattachment(request):
      body = json.loads(request.body)
      if request.method == "POST":
          pk = body['pk']
          skills = body
          res = Resource.objects.filter(pk=pk)
          res.skillset.clear()
          res.skillset.add(skills)
  
      else:
          search_id = ''
  
      return HttpResponse(json.dumps(body), content_type='application/json')
  </code></pre>
  
  <p>Is there  a better way to do what I am trying todo?</p>
  
  <p>I I currently get the error
  'QuerySet' object has no attribute 'skillset'
  though I am unsure why? maybe I have made the M2M incorrectly but I have followed the docs</p>