我正在尝试显示一个链接,该链接会将用户带到这样的 PDF 视图:
@admin.register(Service)
class ServiceAdmin(admin.ModelAdmin):
list_display = ['client', 'description', 'price', 'paid', 'service_actions']
list_select_related = ['client']
list_filter = [('client', admin.RelatedFieldListFilter), 'paid']
actions = [mark_paid]
def service_actions(self, obj):
return format_html('<a class="btn btn-outline-info" href="{}">PDF</a>', reverse("pdf_service", args=[obj.pk])),
service_actions.short_description = 'Actions'
我试过做同样的事情,mark_safe
但给出了相同的结果:
<span class="btn btn-outline-info" href="/%2Fpdf/3">PDF</span>