[Answered ]-Django admin – add custom link to change list view

2πŸ‘

βœ…

In Django 1.9, the admin change url has changed to /admin/<app>/<model>/<pk>/change/ (release notes).

Therefore, it doesn’t make sense to link to href="analyze/" in your html. The relative url is treated as /admin/<app>/<model>/3/change/analyze, not /admin/<app>/<model>/3/analyze as you expect.

You can probably fix the problem by changing the link to:

<a href="../analyze/" ...

Ideally, it would be better to reverse the url rather than having a relative link. I think this would make the code less fragile.

Since you are using Django 1.9, you can update your code to use a list rather than patterns:

from django.conf.urls import url

analyze_url = [
    url(r'^(?P<pk>\d+)/analyze/$', self.admin_site.admin_view(self.analyze_view)),
]
πŸ‘€Alasdair

Leave a comment