Froala Django暂时无法运行

2024-05-15 04:23:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试在我的django项目中使用froala WYSIWYG,我安装并准备了文档中提到的所有内容 但内容字段仍显示为文本字段 有什么解决办法吗??在

我的代码 表单.py在

from django import forms
from .models import BlogPost
from froala_editor.widgets import FroalaEditor

class PostForm(forms.ModelForm):
    content = forms.CharField(widget=FroalaEditor())
    class Meta:
        model = BlogPost
        fields = ('title','body','thumb','tags')

模板

^{pr2}$

请注意

 editor = PostForm(request.POST, request.FILES ) 

在我看来

我在jquery cookies上遇到了麻烦 错误:

Uncaught ReferenceError: getCookie is not defined
    at HTMLDocument.<anonymous> ((index):72)
    at i (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at Function.ready (jquery.min.js:2)
    at HTMLDocument.K (jquery.min.js:2)

Tags: djangofromimport内容jsformsjquerymin
2条回答

我找到了这个答案Using django-froala-editor, the editor works in admin page won't work in post page问题出在Jquery中,我在Froala脚本之前替换了主Jquery文件

你检查过浏览器看文件是否正在加载吗?您同时引用了/static/...{{ STATIC_URL }}...的静态文件,但我建议您使用导入的^{} template tag。看起来像这样:

<link href="{% static 'froala_editor/css/font-awesome.min.css' %}" type="text/css" media="all" rel="stylesheet" />

要实现这一点,您需要在项目的设置中设置Django staticfiles应用程序(如果还没有)。The Django docs将帮助你把那部分整理好。在

相关问题 更多 >

    热门问题