Re: [Django] #28301: Object history is not logged for many to many fields

2017-06-13 Thread Django
#28301: Object history is not logged for many to many fields
-+--
 Reporter:  Karolis Ryselis  |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  contrib.admin|  Version:  1.11
 Severity:  Normal   |   Resolution:  duplicate
 Keywords:   | Triage Stage:  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+--
Changes (by Tim Graham):

 * status:  new => closed
 * resolution:   => duplicate


Comment:

 Duplicate of #27998

--
Ticket URL: 
Django 
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/065.c2c734d9a7fb632f70f1a1b03c6a6841%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #28301: Object history is not logged for many to many fields

2017-06-13 Thread Django
#28301: Object history is not logged for many to many fields
---+
   Reporter:  Karolis Ryselis  |  Owner:  nobody
   Type:  Bug  | Status:  new
  Component:  contrib.admin|Version:  1.11
   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|
---+
 Consider this models.py:

 {{{
 from django.db import models


 class Model1(models.Model):
 title = models.CharField(max_length=20)

 def __str__(self):
 return self.title


 class Model2(models.Model):
 title = models.CharField(max_length=20)
 models1 = models.ManyToManyField(to="Model1")

 def __str__(self):
 return self.title
 }}}

 and this admin.py

 {{{
 from django.contrib import admin

 from .models import Model1, Model2

 admin.site.register(Model1)
 admin.site.register(Model2)
 }}}

 My test scenario:
 1. Add two `Model1` items via admin
 2. Add one `Model2` item via admin, choose one instance of `Model1` for
 many-to-many field
 3. Edit the `Model2` item via admin choosing both `Model1` instances for
 many-to-many field
 4. Open history for `Model2` instance
 5. "No fields changed." is in history even though we have changed one of
 the fields.

 I guess that this could be caused by lazy evaluation of initial queryset.
 Initial data is loaded from model instance using `model_to_dict` which
 calls `f.value_from_object` for each field. `ManyToManyField` implemention
 returns a queryset. It think it is only evaluated when object history
 messages are constructed, i.e., after object is saved to database, and
 queryset returns already saved values instead of initial values. Because
 of this, initial and saved data are always the same and this field never
 appears in `changed_data`.
 I was able to reproduce this on 1.11.2.

--
Ticket URL: 
Django 
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/050.e00fdfb938a233de44f57d9089df6b82%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.