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

后端 未结 8 1124
花落未央
花落未央 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 21:53

    Have you tried {{ message | safe }}?

    In the Django template system template variables are always escaped, unless you specify them as safe with the safe filter. This default makes even the unaware protected against an injection attack.

    I'm not sure how that interacts with mark_safe, but perhaps something happened in between that made it unsafe again.

提交回复
热议问题