﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27998	LogEntry messages do not list m2m fields that were changed when an object is changed via ModelAdmin	ljsjl	ljsjl	"What I expect to happen: m2m fields that are changed via a ModelAdmin in an update are listed in the appropriate change message in that object's history.
What happens: m2m fields are not listed in the generated change message

Reproduction: Create a vanilla Django install. Create a group. Assign a permission to that group. View the group's history, the message will say ""No fields changed.""

Cause: It looks like save_related() is called before form.has_changed() or form.changed_data are evaluated. save_related() calls form.save_m2m() which updates the relationship table. At this point it looks like querysets in the ModelForm form.initial have not been evaluated, so when they are evaluated as part of constructing the change message the database has already been modified by form.save_m2m(), and so the fields are left out of form.changed_data.

Fix: Probably call form.has_changed() at some point before save_related(). Happy to put together a patch for changelist_view and changeform_view if needed and attach to this ticket."	Bug	closed	contrib.admin	1.10	Normal	fixed			Accepted	1	0	0	0	0	0
