Update/Remove Many to Many Field in Django

Viewed 37

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?

1 Answers
Related