3👍
✅
Since you are saving the form with commit=False
, you must call the form’s save_m2m
method after saving the instance.
new_profile = form.save(commit=False)
# no need to fetch the user here, just use request.user
new_profile.user = request.user
new_profile.save()
form.save_m2m()
See the docs on the model form save method for more info.
Source:stackexchange.com