Hey there,

here’s a little topic that impacts the usability of Django admin’s delete 
views.

When deleting an object using django admin, you get a nice summary of all 
deleted objects.
I really like the overview, but the labels used to describe m2m relations 
that will be deleted aren't user-friendly at all:

[…]

   - MediaItem-subseries-relation: MediaItem_sub_series_relation object 
   (11482)
   - MediaItem-piece-relation: MediaItem_pieces_relation object (11773)

So I’d like to improve the labels a bit, using the from and to model’s 
verbose names. This can be easily accomplished by changing 
`create_many_to_many_intermediary_model` in fields/related.py.

To be honest, I don’t know how to update the tests for something rooted 
deeply in Django’s core.Is anyone who is more competent than me interested 
in fixing this? It would greatly improve the “delete confirmation“ views.

Here’s what I’ve got so for; it only fixes the model’s verbose name, not 
its string presentation.

Best regards
Julian


[…]
    to = make_model_tuple(to_model)[1]
    from_ = klass._meta.model_name

    if isinstance(to_model, str):
        to_label = to
        to_label_plural = to
    else:
        to_label = to_model._meta.verbose_name
        to_label_plural = to_model._meta.verbose_name_plural

    from_label = klass._meta.verbose_name
    from_label_plural = klass._meta.verbose_name_plural

    if to == from_:
        to = 'to_%s' % to
        from_ = 'from_%s' % from_

    meta = type('Meta', (), {
        'db_table': field._get_m2m_db_table(klass._meta),
        'auto_created': klass,
        'app_label': klass._meta.app_label,
        'db_tablespace': klass._meta.db_tablespace,
        'unique_together': (from_, to),
        'verbose_name': _('%(from)s-%(to)s relationship') % {'from': 
from_label, 'to': to_label},
        'verbose_name_plural': _('%(from)s-%(to)s relationships') % 
{'from': from_label_plural, 'to': to_label_plural},
        'apps': field.model._meta.apps,
    })


-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/69b6f2e0-8f0e-4cd0-b608-46fb9040b355n%40googlegroups.com.

Reply via email to