I\'m trying to send an email to a user when a new model instance is saved and I want the email to include a link to the admin page for that model instance. Is there a way to get
Not trying to rip off @JosvicZammit, but using ContentType
is the wrong approach here. It's just a wasted DB query. You can get the require info from the _meta
attribute:
from django.urls import reverse
info = (model_instance._meta.app_label, model_instance._meta.model_name)
admin_url = reverse('admin:%s_%s_change' % info, args=(model_instance.pk,))