Q: Update/Remove Many to Many Field in Django I have saved the object in the database with the many to many fields, after saving the object in the database I want to append one more ID in the many to many field so how can I do that in Django.
models.py
class Project(models.Model):
    name = models.CharField(max_length=255, default='')
    description = models.CharField(max_length=255, default='')
    account = models.ManyToManyField(User)

JSON from Frontend
{
  "name": "Project 1",
  "description": "description of project 1",
  "account": [1, 2] 
}

assume the object is saved now, what if I want to add id 3 to the account or remove id 2?

A: p = Project.objects.get(id=1)
u = User.objects.get(id=234)
u.project_set.add(p) #add
u.project_set.remove(p) #remove

Note that you can also to p.account.add() or p.account.remove().
More info here: https://docs.djangoproject.com/en/dev/ref/models/relations/#related-objects-reference
