1👍
✅
The documentation does explain this.
form.save()
includes the creation and saving of M2M relations; this is because the form can do the whole thing in one go. But as soon as you use commit=False
, the form can no longer create the M2M relations, because the object itself has not been saved; an M2M is impossible without an ID to link to.
object.save()
can’t call save_m2m
, because that is an action of the form, not the model instance object. The object doesn’t even know about the m2m relations at this point, because the form couldn’t create them. That’s why you need to call the save_m2m method of the form.
Source:stackexchange.com