#24541: save_new_objects in ModelFromsets do not handle intitial data
-------------------------------+--------------------------------------
     Reporter:  codingjoe      |                    Owner:  nobody
         Type:  Uncategorized  |                   Status:  new
    Component:  Forms          |                  Version:  master
     Severity:  Normal         |               Resolution:
     Keywords:  modelformset   |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------

Comment (by codingjoe):

 Sorry, I think I fixed the example.

 Let me try to be a little more specific to what's wrong:

 There are two ways to pre fill a ModelFormSet, by passing a queryset or
 initial data. The later is described here:
 https://docs.djangoproject.com/en/dev/topics/forms/formsets/#using-
 initial-data-with-a-formset

 Sadly a ModelFormSet only takes `queryset` in account for
 `initial_form_count`
 https://github.com/django/django/blob/master/django/forms/models.py#L579

 Therefore initial data is used for form construction but not accounted for
 form saving, which is very much unexpected.
 https://github.com/django/django/blob/master/django/forms/models.py#L606-L611

--
Ticket URL: <https://code.djangoproject.com/ticket/24541#comment:7>
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/067.564b360b01e76f9e01a66eba5da4bb7e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to