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
This gives the same result as Josvic Zammit's snippet, but does not hit the database:
from django.urls import reverse
from django.db import models
class MyModel(models.Model):
def get_admin_url(self):
return reverse("admin:%s_%s_change" % (self._meta.app_label, self._meta.model_name), args=(self.id,))