#28283: _changeform_view sends wrong object after ModelForm validation
-----------------------------------------+------------------------
               Reporter:  ddein          |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  contrib.admin  |        Version:  master
               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              |
-----------------------------------------+------------------------
 I noticed strange behavior when changing the form of the admin. If I try
 to save the form with an error, some functions (`get_fieldsets`,
 `get_prepopulated_fields`, `get_readonly_fields`, `get_inline_formsets`,
 something else) get the wrong object after validation. See here:
 
https://github.com/django/django/blob/master/django/contrib/admin/options.py#L1436-L1437
 It seems to me not obvious, that after call `is_valid`, object `obj` will
 be changed. The quick solution for me was the following:
 {{{
 form = ModelForm(request.POST, request.FILES, instance=copy.copy(obj))
 }}}
 But maybe the problem elsewhere. Has anyone encountered a similar one, is
 this a mistake or normal behavior?

--
Ticket URL: <https://code.djangoproject.com/ticket/28283>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/048.09906599ae5b3b482b6aa1dfa5573ea3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to