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
- Application-independent permalink to admin url for an object by dchandek 4 years, 2 months ago
- Front end admin toolbar by eallik 2 years, 5 months ago
- CSV Exporting of Model Data by monokrome 2 years, 6 months ago
- ExtendibleModelAdminMixin by dokterbob 2 years, 6 months ago
- Automatic urls for static pages by jibbolo 1 year, 6 months ago
Comments
Nice. Minor tweak, args=(self.pk,) instead, to support models with explicit primary_key.
#