[Django] #33868: Admin “delete object(s)” view: improve labels of m2m relations

0 views
Skip to first unread message

Django

unread,
Jul 26, 2022, 7:57:55 AM7/26/22
to django-...@googlegroups.com
#33868: Admin “delete object(s)” view: improve labels of m2m relations
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
jul...@pinabausch.org |
Type: | Status: new
Cleanup/optimization |
Component: | Version: 4.0
contrib.admin |
Severity: Normal | Keywords: admin, delete view
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When deleting an object that has m2m relations in Django Admin, it shows a
nice overview of what’s going to be deleted, including the records from
m2m relations. Here’s a screenshot of a minimal example:


The labels for the m2m relations are constructed like this:

//Photo-person relationship: Photo_depicts object (1)//

//Photo-person relationship// makes perfect sense to me; //Photo_depicts
object (1)// could be improved.

I suggest using the labels of the string representation of the concrete
from- and to-objects.

Let me know what you think about it and I will see if I can come up with a
patch.

Background:
Two years ago, I had a discussion on the Django developers mailing list
about improving the labels that are used for m2m relations in Django
Admin’s delete view. While reviewing old tickets to day, I checked the
mailing list again and thought “Why not give it another shot?”.
https://groups.google.com/g/django-developers/c/TxZtZyB3kpc

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

Django

unread,
Jul 26, 2022, 7:58:58 AM7/26/22
to django-...@googlegroups.com
#33868: Admin “delete object(s)” view: improve labels of m2m relations
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
jul...@pinabausch.org |
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:

Keywords: admin, delete view | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jul...@pinabausch.org):

* Attachment "Bildschirmfoto 2022-07-26 um 13.48.32.png" added.

Delete view sample – deleting a Photo instance that has a “depcits”
relation to four people

Django

unread,
Jul 26, 2022, 8:00:26 AM7/26/22
to django-...@googlegroups.com
#33868: Admin “delete object(s)” view: improve labels of m2m relations
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
jul...@pinabausch.org |
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin, delete view | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jul...@pinabausch.org):

* cc: jul...@pinabausch.org (added)


Old description:

> When deleting an object that has m2m relations in Django Admin, it shows
> a nice overview of what’s going to be deleted, including the records from
> m2m relations. Here’s a screenshot of a minimal example:
>

> The labels for the m2m relations are constructed like this:
>
> //Photo-person relationship: Photo_depicts object (1)//
>
> //Photo-person relationship// makes perfect sense to me; //Photo_depicts
> object (1)// could be improved.
>
> I suggest using the labels of the string representation of the concrete
> from- and to-objects.
>
> Let me know what you think about it and I will see if I can come up with
> a patch.
>
> Background:
> Two years ago, I had a discussion on the Django developers mailing list
> about improving the labels that are used for m2m relations in Django
> Admin’s delete view. While reviewing old tickets to day, I checked the
> mailing list again and thought “Why not give it another shot?”.
> https://groups.google.com/g/django-developers/c/TxZtZyB3kpc

New description:

When deleting an object that has m2m relations in Django Admin, it shows a
nice overview of what’s going to be deleted, including the records from

m2m relations. An example screenshot is attached to the ticket.


The labels for the m2m relations are constructed like this:

//Photo-person relationship: Photo_depicts object (1)//

//Photo-person relationship// makes perfect sense to me; //Photo_depicts
object (1)// could be improved.

I suggest using the labels of the string representation of the concrete
from- and to-objects.

Let me know what you think about it and I will see if I can come up with a
patch.

Background:
Two years ago, I had a discussion on the Django developers mailing list
about improving the labels that are used for m2m relations in Django
Admin’s delete view. While reviewing old tickets to day, I checked the
mailing list again and thought “Why not give it another shot?”.
https://groups.google.com/g/django-developers/c/TxZtZyB3kpc

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33868#comment:1>

Django

unread,
Jul 26, 2022, 4:24:47 PM7/26/22
to django-...@googlegroups.com
#33868: Admin “delete object(s)” view: improve labels of m2m relations
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
jul...@pinabausch.org |
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin, delete view | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by jul...@pinabausch.org:

Old description:

> When deleting an object that has m2m relations in Django Admin, it shows
> a nice overview of what’s going to be deleted, including the records from

New description:

**Update:**
Here’s a possible fix: https://github.com/django/django/pull/15884
Some remarks:
* It may be necessary to use a custom manager for the intermediary model
to Ticket gets some attention
* This is not a change to django admin (as planned), but it affects *all*
auto-generated m2m models . What are the ceveats?
* Translations are missing currently
* I'm happy to provide tests if this goes in the right direction

Background:
Two years ago, I had a discussion on the Django developers mailing list
about improving the labels that are used for m2m relations in Django
Admin’s delete view. While reviewing old tickets to day, I checked the
mailing list again and thought “Why not give it another shot?”.
https://groups.google.com/g/django-developers/c/TxZtZyB3kpc

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33868#comment:2>

Django

unread,
Jul 26, 2022, 4:27:45 PM7/26/22
to django-...@googlegroups.com
#33868: Admin “delete object(s)” view: improve labels of m2m relations
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
jul...@pinabausch.org |
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin, delete view | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jul...@pinabausch.org):

* has_patch: 0 => 1
* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/33868#comment:3>

Django

unread,
Jul 26, 2022, 4:30:12 PM7/26/22
to django-...@googlegroups.com
#33868: Admin “delete object(s)” view: improve labels of m2m relations
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
jul...@pinabausch.org |
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin, delete view | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jul...@pinabausch.org):

* Attachment "Bildschirmfoto 2022-07-26 um 22.28.39.png" added.

Sample delete view with improved labels

Django

unread,
Jul 26, 2022, 4:34:29 PM7/26/22
to django-...@googlegroups.com
#33868: Admin “delete object(s)” view: improve labels of m2m relations
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
jul...@pinabausch.org |
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin, delete view | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by jul...@pinabausch.org:

Old description:

> When deleting an object that has m2m relations in Django Admin, it shows
> a nice overview of what’s going to be deleted, including the records from
> m2m relations. An example screenshot is attached to the ticket.
>

> The labels for the m2m relations are constructed like this:
>
> //Photo-person relationship: Photo_depicts object (1)//
>
> //Photo-person relationship// makes perfect sense to me; //Photo_depicts
> object (1)// could be improved.
>
> I suggest using the labels of the string representation of the concrete
> from- and to-objects.
>
> Let me know what you think about it and I will see if I can come up with
> a patch.
>

New description:

* The `from` and `to` models should be fetched with `select_related`
before `__str__` is called


* This is not a change to django admin (as planned), but it affects *all*
auto-generated m2m models . What are the ceveats?
* Translations are missing currently
* I'm happy to provide tests if this goes in the right direction

Background:
Two years ago, I had a discussion on the Django developers mailing list
about improving the labels that are used for m2m relations in Django
Admin’s delete view. While reviewing old tickets to day, I checked the
mailing list again and thought “Why not give it another shot?”.
https://groups.google.com/g/django-developers/c/TxZtZyB3kpc

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33868#comment:4>

Django

unread,
Aug 2, 2022, 5:37:42 AM8/2/22
to django-...@googlegroups.com
#33868: Admin “delete object(s)” view: improve labels of m2m relations
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
jul...@pinabausch.org |
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin, delete view | Triage Stage: Accepted

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

* cc: Adam Johnson (added)
* stage: Unreviewed => Accepted


Comment:

OK, thanks Julian — let's take this for review, since the discussion with
Adam was broadly positive (pending any possible blockers).

--
Ticket URL: <https://code.djangoproject.com/ticket/33868#comment:5>

Django

unread,
Nov 22, 2022, 4:47:24 AM11/22/22
to django-...@googlegroups.com
#33868: Admin “delete object(s)” view: improve labels of m2m relations
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
jul...@pinabausch.org |
Type: | Status: closed

Cleanup/optimization |
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution: wontfix

Keywords: admin, delete view | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jul...@pinabausch.org):

* status: new => closed
* resolution: => wontfix


Comment:

Closing this – the improved labels can only be implemented by fetching the
“from” and “to” instances from the database, i.e. introducing a
performance regression. The current implementation’s labels are created
based on the models’ verbose names and the m2m instance’s ID, which is
quite performance-friendly.

--
Ticket URL: <https://code.djangoproject.com/ticket/33868#comment:6>

Django

unread,
Nov 22, 2022, 4:50:04 AM11/22/22
to django-...@googlegroups.com
#33868: Admin “delete object(s)” view: improve labels of m2m relations
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
jul...@pinabausch.org |
Type: | Status: closed
Cleanup/optimization |
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution: wontfix
Keywords: admin, delete view | Triage Stage:
| Unreviewed

Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Unreviewed


Comment:

Closing as "wonfix" due to backward compatibility concerns and a possible
performance regression. Users can always override `__str__` in their app,
e.g.
{{{#!python
class FirstModel(models.Model):
pass


class SecondModel(models.Model):
firsts = models.ManyToManyField(FirstModel)


def to_str(self):
return f"between {self.firstmodel} and {self.secondmodel}"


SecondModel.firsts.through.__str__ = to_str
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33868#comment:7>

Reply all
Reply to author
Forward
0 new messages