[Fixed]-Django form with many-to-many relationship does not save

30👍

Since you use commit=false for the super(RegistrationForm, self).save call, it doesn’t save the many-to-many field. You therefore need to add self.save_m2m() after user.save() in your save() method of RegistrationForm.

See https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method

EDIT: save_m2m() is on the Form, not the Model

Leave a comment