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. Generic AJAX app by Rupe 3 years, 11 months ago
  2. Filter by taggit tags in the admin by flupke 1 year, 7 months ago
  3. Clean Reversion History: Remove unimportant Changes by guettli 1 year, 3 months ago
  4. Create short URL redirects for site urls. by matt.geek.nz 4 years, 3 months ago
  5. Send information mails to related staff members. by sleytr 5 years, 11 months ago

Comments

(Forgotten your password?)