Application-independent permalink to admin url for an object

1
2
3
4
5
6
7
8
9
from django.db.models import permalink

@permalink
def get_admin_url(obj):
    "Returns the URL to the object in the Django admin site."
    from django.contrib.contenttypes.models import ContentType
    content_type = ContentType.objects.get_for_model(obj)
    return ('django.contrib.admin.views.main.change_stage', 
            [content_type.app_label, content_type.model, str(obj.pk)])

More like this

  1. Get admin url for a model by timbroder 2 years ago
  2. Changelist filter by ForeignKey by overclocked 1 year, 2 months ago
  3. ExtendibleModelAdminMixin by dokterbob 2 years, 2 months ago
  4. Default to current/all sites in admin (updated!) by dokterbob 3 years, 4 months ago
  5. Front end admin toolbar by eallik 2 years, 2 months ago

Comments

(Forgotten your password?)