Tips
- allow_tags: 允许显示超链接
- short_description: 显示的字段名
from django.contrib import admin
from django.utils.html import format_html
from .models import ModelsExample
@admin.register(ModelsExample)
class AdminExample(admin.ModelAdmin):
list_display = ['filename', 'MD5', 'link', 'create_timestamp']
ordering = ['-id']
list_per_page = 50
url = "xxx" # 跳转的超链接
url_text = "link" # 显示的文本
def link(self, obj):
return format_html(u'<a href="{}" target="_blank">{}</a>'.format(url, url_text))
link.allow_tags = True
link.short_description = "ColsName"
效果
### 微信公众号二维码
来源:CSDN
作者:Theo仔
链接:https://blog.csdn.net/ForeverLyu/article/details/104319910