Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在SuccessMessagexin中嵌入HTML?_Python_Django_Message - Fatal编程技术网

Python 如何在SuccessMessagexin中嵌入HTML?

Python 如何在SuccessMessagexin中嵌入HTML?,python,django,message,Python,Django,Message,如何在这里嵌入html代码。我试着用mark_保险柜,但没用 class PostCreateView(SuccessMessageMixin, LoginRequiredMixin, CreateView): model = Post form_class = PostForm template_name = 'blogApp/create.html' success_url = '/' success_message = mark_safe(

如何在这里嵌入html代码。我试着用mark_保险柜,但没用

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')
class PostCreateView(SuccessMessageMaxin、LoginRequiredMixin、CreateView):
型号=员额
form_class=PostForm
模板名称='blogApp/create.html'
成功_url='/'
成功消息=标记安全(
“%(标题)s创建成功”
提前谢谢你

你可以试试这个:

success_message = "<h1>hello</h1>"

哈,我是如此痴迷于在视图中使用它,以至于我完全忘记了我可以在模板中过滤它
{{message|safe}}