I have a model exposed in Django’s admin, which uses ModelAdmin’s readonly_fields list to show a “user” field, which is a ForiegnKey linking to Django’s User model. By default, readonly_fields causes this field to be rendered as simple text containing the user’s email (e.g. someuser@domain.com). How would I change this to render as a link to the associated admin page for that user? (e.g. <a href="/admin/auth/user/123/">someuser@domain.com</a>)
I have a model exposed in Django’s admin, which uses ModelAdmin’s readonly_fields list to
Share
Digging into the source code, I found you can essentially define your own fields as methods within your ModelAdmin subclass, and you can get the field to render as a link by simply returning the link html from the method.
e.g.