Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#30268 closed Cleanup/optimization (invalid)

Django admin list_editable overrides changes done elsewhere

Reported by: Brillgen Developers Owned by: nobody
Component: contrib.admin Version: 2.1
Severity: Normal Keywords: admin
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If a field is made list_editable, all the objects displayed on the page are overridden even if they are not changed when save is pressed on the django admin changelist page.

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

Change History (3)

comment:1 by Carlton Gibson, 6 years ago

Resolution: invalid
Status: newclosed

Hi. This looks invalid.

When processing the list_editable submission, 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.

comment:2 by Tim Graham, 6 years ago

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.

comment:3 by Carlton Gibson, 6 years ago

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.)

Version 0, edited 6 years ago by Carlton Gibson (next)
Note: See TracTickets for help on using tickets.
Back to Top