[Django] #30268: Django admin list_editable overrides changes done elsewhere

11 views
Skip to first unread message

Django

unread,
Mar 19, 2019, 8:20:04 AM3/19/19
to django-...@googlegroups.com
#30268: Django admin list_editable overrides changes done elsewhere
------------------------------------------------+------------------------
Reporter: Brillgen Developers | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.admin | Version: 2.1
Severity: Normal | Keywords: admin
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
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

--
Ticket URL: <https://code.djangoproject.com/ticket/30268>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 21, 2019, 7:03:21 AM3/21/19
to django-...@googlegroups.com
#30268: Django admin list_editable overrides changes done elsewhere
-------------------------------------+-------------------------------------

Reporter: Brillgen Developers | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution: invalid

Keywords: admin | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* 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>

Django

unread,
Mar 21, 2019, 8:20:51 AM3/21/19
to django-...@googlegroups.com
#30268: Django admin list_editable overrides changes done elsewhere
-------------------------------------+-------------------------------------

Reporter: Brillgen Developers | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution: invalid

Keywords: admin | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Mar 21, 2019, 10:03:14 AM3/21/19
to django-...@googlegroups.com
#30268: Django admin list_editable overrides changes done elsewhere
-------------------------------------+-------------------------------------

Reporter: Brillgen Developers | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution: invalid

Keywords: admin | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Reply all
Reply to author
Forward
0 new messages