How do I output HTML in a message in the new Django messages framework?

后端 未结 8 1113
花落未央
花落未央 2020-12-04 21:37

I\'m trying to display a bit of html in a message that\'s being displayed via the new Django messages framework. Specifically, I\'m doing this via the ModelAdmin.message_use

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-04 22:05

    This worked for me (Django 1.11):

    from django.contrib import messages
    from django.utils.safestring import mark_safe
    
    messages.info(request, mark_safe('This is link to http://google.com'))
    

提交回复
热议问题