1 2 3 4 5 6 | from django.core import urlresolvers
from django.contrib.contenttypes.models import ContentType
def get_admin_url(self):
content_type = ContentType.objects.get_for_model(self.__class__)
return urlresolvers.reverse("admin:%s_%s_change" % (content_type.app_label, content_type.model), args=(self.id,))
|
More like this
- Front end admin toolbar by eallik 3 years, 5 months ago
- Additional Change List Columns by sansmojo 5 years, 10 months ago
- Read more link by nny777 4 years, 10 months ago
- Admin: return to change_list with filter and pagination applied by fx 2 years, 1 month ago
- Redirect with change list with filters intact with admin actions by AndrewIngram 3 years, 10 months ago
Comments
Nice. Minor tweak, args=(self.pk,) instead, to support models with explicit primary_key.
#
You can do it without using a query to ContentTypes!
#