There is a way this can be handled:
- Keep a hidden field with the original value and only save when the
hidden field is different from the value in the form field
This can be a option in the admin if we are worried about making the page
heavier than it needs to be
--
Ticket URL: <https://code.djangoproject.com/ticket/30268>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
Comment:
Hi. This looks invalid.
When processing the `list_editable` submission,
[https://github.com/django/django/blob/413d50b5ff0c0a4198d4bf069e6434bc7ba4cd86/django/contrib/admin/options.py#L1728-L1731
each form is only saved if there are edits]:
{{{
if formset.is_valid():
changecount = 0
for form in formset.forms:
if form.has_changed():
#... obj is updated...
}}}
That looks like the behaviour you're suggesting.
If I've misunderstood, please provide a minimal test case or project
showing the incorrect behaviour and we can have a look.
Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/30268#comment:1>
Comment (by Tim Graham):
Yes, but the initial data that `form.has_changed()` uses is from the
database at the time the form is submitted rather than the data displayed
with the original form.
--
Ticket URL: <https://code.djangoproject.com/ticket/30268#comment:2>
Comment (by Carlton Gibson):
Yes, thanks for commenting Tim. This limitation has come up before: ref at
least #11313 but there was some discussion more recently around #28462
too.
There was a fix suggests on the mailing list here:
https://groups.google.com/d/topic/django-
developers/ySxRIV3g6XQ/discussion. #11652 and #16549 were referenced
there.
#11652 looks to directly wish to address this but was closed as not really
realistic to implement, with an invite the suggest something on the
DevelopersMailingList.
(It would be a good addition if it did turn up though.)
--
Ticket URL: <https://code.djangoproject.com/ticket/30268#comment:3>