Changelist links for proxy model admins

78 views
Skip to first unread message

Niccolò Mineo

unread,
Oct 17, 2021, 11:00:06 AM10/17/21
to Django developers (Contributions to Django itself)
Hi.

When one is displaying a proxy model admin I think It could be nice to automatically override the default behaviour for instances in the changelist and have them redirect to the proxy URL, instead of the default, non-proxy one.

What do you think?

I can prepare a PR.

Adam Johnson

unread,
Oct 20, 2021, 12:20:22 PM10/20/21
to django-d...@googlegroups.com
Hi Niccolò

I suspect no one has replied to your thread because your use case is too niche. Perhaps try showing the issue with more words and more visually with a screenshot or two.

To me it sounds like "the admin links to the wrong place for proxy models" which sounds like a plain bug, and if that is the case you could directly open a ticket.

—Adam

--
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-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/26c430ca-9896-4ab7-832b-369e515afcc8n%40googlegroups.com.

Niccolò Mineo

unread,
Oct 20, 2021, 2:14:03 PM10/20/21
to Django developers (Contributions to Django itself)
Hi Adam,

let me explain with one use case (I believe there's at least one more, but it doesn't matter for example's sake):

say you have a model Employee with two proxy models DeliveryPerson and CallCenterOperator, but only Employee has a ModelAdmin.

You get to the Employee admin changelist and each instance's link is in the form of /admin/employees/employee/{pk}/.

What you would like to have sometimes is that links actually follow the structure of the proxy model they point to.

So, if one Employee instance is actually a DeliveryPerson, then I may want to have its own link on the changelist to be /admin/employees/deliveryperson/{pk}/, instead of the  /admin/employees/employee/{pk}/.

Right now this is possible by overriding one of the response methods in the ModelAdmin, but I would find very useful a boolean attribute ("proxy_changelist_links" maybe?) on the ModelAdmin for the same purpose.
Reply all
Reply to author
Forward
0 new messages