I have a django admin interface and in the model listing I want a custom column that will be a hyperlink using one of the fields values. Basically one of the models’ fields is a url and i’d like the column to have that URL in a clickable hyperlink. This link will need to have additional URL prepended to it as its a relative path in the model field.
Share
Define a method in your ModelAdmin-class and set its
allow_tagsattribute toTrue. This will allow the method to return unescaped HTML for display in the column.Then list it as an entry in the ModelAdmin.list_display attribute.
Example:
See the documentation for ModelAdmin.list_display for more details.