Re: [Django] #28543: ModelForm.initial is affected while its bound instance's m2m field be set with new data

2017-08-31 Thread Django
#28543: ModelForm.initial is affected while its bound instance's m2m field be 
set
with new data
-+-
 Reporter:  Wonder   |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  form | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Tim Graham ):

 In [changeset:"20c03399d8fd03484f3ed33d93691c29c2ff5aaf" 20c0339]:
 {{{
 #!CommitTicketReference repository=""
 revision="20c03399d8fd03484f3ed33d93691c29c2ff5aaf"
 [1.11.x] Fixed #27998, #28543 -- Restored logging of ManyToManyField
 changes in admin's object history.

 And prevented ManyToManyField initial data in model forms from being
 affected
 by subsequent model changes.

 Regression in 56a55566a791a11420fe96f745b7489e756fc931.

 Partial backport of e5bd585c6eb1e13e2f8aac030b33c077b0b70c05 and
 15b465c584f49a1d43b6c18796f83521ee4ffc22 from master
 }}}

-- 
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/070.7327c1d7955403f88858c2c6e874c806%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28543: ModelForm.initial is affected while its bound instance's m2m field be set with new data

2017-08-31 Thread Django
#28543: ModelForm.initial is affected while its bound instance's m2m field be 
set
with new data
-+-
 Reporter:  Wonder   |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  form | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by GitHub ):

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


Comment:

 In [changeset:"e5bd585c6eb1e13e2f8aac030b33c077b0b70c05" e5bd585]:
 {{{
 #!CommitTicketReference repository=""
 revision="e5bd585c6eb1e13e2f8aac030b33c077b0b70c05"
 Fixed #28543 -- Prevented ManyToManyField.value_from_object() from being
 lazy.

 Previously, it was a QuerySet which could reevaluate to a new value if the
 model's data changes. This is inconsistent with other
 Field.value_from_object()
 methods.

 This allows reverting the fix in the admin for refs #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/070.24c41bf4e7a7cf8cc25e33fe939ef53c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28543: ModelForm.initial is affected while its bound instance's m2m field be set with new data

2017-08-30 Thread Django
#28543: ModelForm.initial is affected while its bound instance's m2m field be 
set
with new data
-+-
 Reporter:  Wonder   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  form | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Tim Graham):

 I found that #27998 is a regression in Django 1.10 due to
 ded502024191053475bac811d365ac29dca1db61. The proposed patch here fixes
 that issue in a better way (at the form level, rather than only in the
 admin) but, with respect to the decision of how to fix that on
 stable/1.11.x, changing the return type of
 `ManyToManyField.value_from_object()` may be too risky for a stable
 release. Perhaps a less invasive fix for 1.11.x would restore the queryset
 to list conversion for ManyToManyFields in `model_to_dict()`.

-- 
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/070.a96271880896af6ef6f24821abbe5562%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28543: ModelForm.initial is affected while its bound instance's m2m field be set with new data

2017-08-30 Thread Django
#28543: ModelForm.initial is affected while its bound instance's m2m field be 
set
with new data
-+-
 Reporter:  Wonder   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  1.11
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  form | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Tim Graham):

 * type:  Uncategorized => Bug
 * has_patch:  0 => 1
 * component:  Uncategorized => Database layer (models, ORM)
 * stage:  Unreviewed => Accepted


Comment:

 The lazy behavior of `ManyToManyField.value_from_object()` seems
 inconsistent with other fields. Fixing this would allow reverting the
 admin-specific fix for #27998.

 [https://github.com/django/django/pull/8992 PR]

-- 
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/070.fa71c8e2243ace558711bda6d9f75f1f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28543: ModelForm.initial is affected while its bound instance's m2m field be set with new data

2017-08-29 Thread Django
#28543: ModelForm.initial is affected while its bound instance's m2m field be 
set
with new data
---+--
 Reporter:  Wonder |Owner:  nobody
 Type:  Uncategorized  |   Status:  new
Component:  Uncategorized  |  Version:  1.11
 Severity:  Normal |   Resolution:
 Keywords:  form   | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by Wonder):

 >> The issue of ManyToManyFields not appearing in the admin's change
 history is fixed in master by #27998. Is there another issue present? I'm
 unsure since your steps to reproduce don't involve the admin.
 > Yes, It may affect not only m2m-fields change in admin.

-- 
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/070.963bdc80c083d320107a513676f289cf%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28543: ModelForm.initial is affected while its bound instance's m2m field be set with new data

2017-08-29 Thread Django
#28543: ModelForm.initial is affected while its bound instance's m2m field be 
set
with new data
---+--
 Reporter:  Wonder |Owner:  nobody
 Type:  Uncategorized  |   Status:  new
Component:  Uncategorized  |  Version:  1.11
 Severity:  Normal |   Resolution:
 Keywords:  form   | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by Tim Graham):

 The issue of ManyToManyFields not appearing in the admin's change history
 is fixed in master by #27998. Is there another issue present? I'm unsure
 since your steps to reproduce don't involve the admin.

-- 
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/070.0f177abc296afd3a8f3cdaf20c229f85%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #28543: ModelForm.initial is affected while its bound instance's m2m field be set with new data

2017-08-29 Thread Django
#28543: ModelForm.initial is affected while its bound instance's m2m field be 
set
with new data
-+
   Reporter:  Wonder |  Owner:  nobody
   Type:  Uncategorized  | Status:  new
  Component:  Uncategorized  |Version:  1.11
   Severity:  Normal |   Keywords:  form
   Triage Stage:  Unreviewed |  Has patch:  0
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+
 I found Django's admin log always doesn't include m2m-fields' change. So I
 looked into django source and found here:
 
https://github.com/django/django/blob/1.11.4/django/contrib/admin/options.py#L1410.

 After this line `self.save_related(request, form, formsets, not add)`,
 `form.initial` is also changed to the saved version, then affect
 `form.changed_data`.

 Then I wrote some test code to reproduce the issue:

 {{{
 #!python
 import datetime as dt
 from django.contrib.auth.forms import UserChangeForm
 from django.contrib.auth import get_user_model
 from django.contrib.auth.models import Group

 User = get_user_model()

 g1=Group.objects.get_or_create(name='g1')[0]
 g2=Group.objects.get_or_create(name='g2')[0]
 user = User.objects.get_or_create(username='wonder')[0]
 user.groups.set([g1])

 form = UserChangeForm({
 'username': 'wonder',
 'date_joined': dt.datetime.now(),
 }, instance=user)
 assert form.is_valid()

 form.initial['groups']  # Out: ]>
 user.groups.set([g2])
 form.initial['groups']  # Out: ]>
 }}}

 Note the two comments in the code.

-- 
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/055.70dec82b9917a454c0c18e9d7018c862%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.