I believe the cause is in
[https://github.com/django/django/blob/main/django/forms/models.py#L942].
`form.has_changed()` checks whether data is different compared to initial
values. This behaviour is incosistent with `form.save()` e.g. you could
call something like `formset.extra_forms[0].save()` and this would save
the form.
It seems reasonable to me to simple remove that line! Why would a new item
not be saved on Submit?
Happy to submit the according PR.
--
Ticket URL: <https://code.djangoproject.com/ticket/33534>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
Comment:
Formsets can have extra forms that may not be changed. In that case, they
shouldn't be treated as new data that the user submitted.
--
Ticket URL: <https://code.djangoproject.com/ticket/33534#comment:1>
Comment (by saschahofmann):
I guess that makes sense if an extra_form is invalid/not filled out but if
I submit a correctly filled out form I would expect it to be saved or not?
Maybe it'd be nice to be able to configure that behaviour? Right now, I am
going to overwrite the save_new_objects function and remove the line.
Replying to [comment:1 Tim Graham]:
> Formsets can have extra forms that may not be changed. In that case,
they shouldn't be treated as new data that the user submitted.
--
Ticket URL: <https://code.djangoproject.com/ticket/33534#comment:2>
Comment (by Tim Graham):
There's a discussion in #24541 which documented the behavior. I don't know
that the use case is common enough to warrant a new option. A set of
completely prefilled forms that require no input from the user seems quite
niche.
--
Ticket URL: <https://code.djangoproject.com/ticket/33534#comment:3>