Changes between Initial Version and Version 1 of Ticket #34802


Ignore:
Timestamp:
Aug 29, 2023, 7:24:54 AM (13 months ago)
Author:
Wicher Minnaard
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34802 – Description

    initial v1  
    11== Status quo
    22Currently, the `django.contrib.admin.actions.delete_selected()` Admin action [https://github.com/django/django/blob/4.2.4/django/contrib/admin/actions.py#L52-L57 will display a feedback message] via the Messages framework reporting on how many objects have been deleted. But in reality the number displayed is an estimate based on an earlier query (for the confirmation dialog) rather than the actual number of objects eventually deleted.
    3 Usually this is not a problem; it's a matter of the user's flavour of semantics: do they expect to see '''(a)''' the count of objects that are no more, regardless of whether ''they'' have been the one to delete them (perhaps some got deleted concurrently)? Or do they expect to see '''(b)''' the count of objects deleted by cause of their exact action and by their exact action only?
     3Usually this is not a problem; it's a matter of the user's flavour of semantics: do they expect to see '''[=#sem-a (a)]''' the count of objects that are no more, regardless of whether ''they'' have been the one to delete them (perhaps some got deleted concurrently)? Or do they expect to see '''[=#sem-b (b)]''' the count of objects deleted by cause of their exact action and by their exact action only?
    44
    55There is no universally correct answer here, but I think we should assume that the current behaviour of '''(a)''' should not be changed.
     
    2222
    2323Whether "''not doing some of that deletion process''" falls under "''customization''" is up for debate.
    24 Also, what are the alternatives? Ideally the queryset for the interstitial confirmation dialog would be easy to override, so that the developer could raise the warning about excluding the two objects there and then, and as a side effect the interstitial will display the correct candidate objects right there, '''''and''''' in the subsequent "''Successfully deleted [...]''" message.
     24Also, what are the alternatives? Ideally the queryset for the interstitial confirmation dialog would be easy to override, so that the developer could raise the warning about excluding the two objects there and then, and as a side effect the interstitial will display the correct candidate objects right there, '''''and''''' display a correct count (conforming to the status quo semantics flavour [#sem-a (a)]) in the subsequent "''Successfully deleted [...]''" message.
    2525
    2626== Proposed solutions
    27271. Make queryset for interstitial overridable as suggested above in '''Discussion'''.
    2828or
    29 2. Let `delete_queryset()` optionally return a count of actually deleted objects. Currently the method doesn't return anything, thus it is straightforward to provide backward compatibility: if nothing (`None`) is returned, the current behaviour persists, but if a count is returned, then that count will go into the message raised. As a side effect, this will flip the count semantics discussed under '''Status quo''' from '''(b)''' to '''(a)''', which could be held against this solution.
     292. Let `delete_queryset()` optionally return a count of actually deleted objects. Currently the method doesn't return anything, thus it is straightforward to provide backward compatibility: if nothing (`None`) is returned, the current behaviour persists, but if a count is returned, then that count will go into the message raised. As a side effect, this will flip the count semantics discussed under '''Status quo''' from '''[#sem-a (a)]''' to '''[#sem-b (b)]''', which could be held against this solution.
    3030
    3131I regard solution '''1''' as the superior, neatest solution, yet solution '''2''' is just a quick patch away (patch attached as an example, I'm happy to make a PR for it).
Back to Top