1👍
You can’t assign ManyToMany field in the model’s constructor. Moreover you can’t set the M2M field to unsaved instance. So you have to save the instance first and then assign the M2M field:
mybook = Author.objects.create(title="The Prince", publisher=mas,
publication_date=date(1989, 6, 30))
mybook.authors.add(mak) # or mybook.authors = [mak]
Source:stackexchange.com