Add this to your model:
def user_link(self):
return '<a href="%s">%s</a>' % (reverse("admin:auth_user_change", args=(self.user.id,)) , escape(self.user))
user_link.allow_tags = True
user_link.short_description = "User"
You might also need to add the following to the top of models.py
:
from django.template.defaultfilters import escape
from django.core.urls import reverse
In admin.py
, in list_display
, add user_link
:
list_display = ('name', 'user_link', )
No need for list_display_links
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…