Opened 2 years ago

Closed 2 years ago

#34187 closed New feature (fixed)

UserCreationForm should save data from ManyToMany form fields

Reported by: Mark Gensler Owned by: Mark Gensler
Component: contrib.auth Version: dev
Severity: Normal Keywords: UserCreationForm save_m2m
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When using contrib.auth.forms.UserCreationForm with a custom User model which has ManyToManyField fields, the data in all related form fields (e.g. a ModelMultipleChoiceField) is not saved.

This is because unlike its parent class django.forms.ModelForm, UserCreationForm.save(commit=True) omits to call self.save_m2m().

This has been discussed on the #django-developers mailing list https://groups.google.com/u/1/g/django-developers/c/2jj-ecoBwE4 and I'm ready to work on a PR.

Change History (8)

comment:1 by Mark Gensler, 2 years ago

Needs tests: set

comment:2 by Mark Gensler, 2 years ago

Component: contrib.admincontrib.auth

comment:3 by Mark Gensler, 2 years ago

Needs tests: unset

comment:4 by Mark Gensler, 2 years ago

Has patch: set

comment:5 by Mariusz Felisiak, 2 years ago

Triage Stage: UnreviewedAccepted
Version: 4.1dev

Sounds reasonable.

PR

Version 0, edited 2 years ago by Mariusz Felisiak (next)

comment:6 by Mariusz Felisiak, 2 years ago

Needs documentation: set

comment:7 by Mariusz Felisiak, 2 years ago

Needs documentation: unset
Triage Stage: AcceptedReady for checkin

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

Resolution: fixed
Status: assignedclosed

In 9d726c7:

Fixed #34187 -- Made UserCreationForm save many-to-many fields.

Note: See TracTickets for help on using tickets.
Back to Top