如何在 SuccessMessageMixin 中嵌入 HTML?
How to embed HTML in SuccessMessageMixin?
如何在此处嵌入 html 代码。我尝试使用 mark_safe,它没有用
class PostCreateView(SuccessMessageMixin, LoginRequiredMixin, CreateView):
model = Post
form_class = PostForm
template_name = 'blogApp/create.html'
success_url = '/'
success_message = mark_safe(
'<strong>%(title)s</strong> Created Successfully')
提前致谢
你可以试试这个:
success_message = "<h1>hello</h1>"
现在在您的 html 中,您正在呈现消息的地方
像这样放置一个安全过滤器:
{{message|safe}}
如何在此处嵌入 html 代码。我尝试使用 mark_safe,它没有用
class PostCreateView(SuccessMessageMixin, LoginRequiredMixin, CreateView):
model = Post
form_class = PostForm
template_name = 'blogApp/create.html'
success_url = '/'
success_message = mark_safe(
'<strong>%(title)s</strong> Created Successfully')
提前致谢
你可以试试这个:
success_message = "<h1>hello</h1>"
现在在您的 html 中,您正在呈现消息的地方
像这样放置一个安全过滤器:
{{message|safe}}