#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, 17 months ago

Needs tests: set

comment:2 by Mark Gensler, 17 months ago

Component: contrib.admincontrib.auth

comment:3 by Mark Gensler, 17 months ago

Needs tests: unset

comment:4 by Mark Gensler, 17 months ago

Has patch: set

comment:5 by Mariusz Felisiak, 17 months ago

Triage Stage: UnreviewedAccepted
Version: 4.1dev

Sounds reasonable, see also comment.

PR

Last edited 17 months ago by Mariusz Felisiak (previous) (diff)

comment:6 by Mariusz Felisiak, 17 months ago

Needs documentation: set

comment:7 by Mariusz Felisiak, 17 months ago

Needs documentation: unset
Triage Stage: AcceptedReady for checkin

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 17 months 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