Changes between Version 1 and Version 2 of Ticket #28608, comment 6


Ignore:
Timestamp:
Jan 22, 2019, 6:24:40 AM (6 years ago)
Author:
Lemuel Formacil

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28608, comment 6

    v1 v2  
    55> To work around this problem, every time you save a form using `commit=False`, Django adds a `save_m2m()` method to your `ModelForm` subclass. After you’ve manually saved the instance produced by the form, you can invoke `save_m2m()` to save the many-to-many form data.
    66
    7 However, the `UserCreationForm.save` method initially calls the form's save method with `commit=False` but then doesn't call the `save_m2m` method within the `if commit:` block.  The save method should be something like this so the form would behave as expected with custom user models with a many-to-many relation:
     7However, the `UserCreationForm.save()` method initially calls the form's save method with `commit=False` but then doesn't call the `save_m2m` method after committing the instance if `commit=True`.  The `save()` method should be something like this so the form would behave as expected with custom user models with a many-to-many relation:
    88
    99{{{
Back to Top