#27998: LogEntry messages do not list m2m fields that were changed when an 
object
is changed via ModelAdmin
-----------------------------------------+------------------------
               Reporter:  ljsjl          |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  contrib.admin  |        Version:  1.10
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/27998>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/048.777327f0e0ed02103a1075cb30707d17%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to