Link from Django Model's "absolute url" to its admin page

Question:

According to the docs, you can specify a get_absolute_url in your Django Model for a "View on site" button to show up on Django Admin.

However, how would you do the opposite? A link on the above defined "absolute url" that takes you to the admin page for that instance? I can think of ways to hardcode the admin url and fill in just the instance ID, but I was hoping for a pythonic way (e.g. instance.get_admin_url())

Thanks for the help!

Asked By: Krishnan Shankar

||

Answers:

here is a description of named urls from admin which you can use in reverse() or in template url tag:

https://docs.djangoproject.com/en/4.2/ref/contrib/admin/#reversing-admin-urls

Answered By: Razenstein