使用django-froala-editor,在admin页面中的编辑器工作在post页面中不起作用?未捕获的TypeError:$(…)。froalaEditor不是函数

对不起,如果我以前的post不清楚。 我正在使用django-froala-editor, https://github.com/froala/django-froala-editor但它不会起作用。 我记得在我的上一个项目中使用它,但这次它不起作用。 我安装并配置了它,在管理页面内它可以工作,但在管理页面外它不起作用。 我按照医生说{{form.media}}做了,但它不起作用。 在控制台中,我得到U $(…)。froalaEditor不是一个函数

 $(function(){ $('#id_content').froalaEditor({"imageUploadURL": "/froala_editor/image_upload/", "fileUploadParams": {"csrfmiddlewaretoken": getCookie("csrftoken")}, "inlineMode": false, "fileUploadURL": "/froala_editor/file_upload/", "imageUploadParams": {"csrfmiddlewaretoken": getCookie("csrftoken")}}) });  

我没有写。 我有这个

  {{ form | as_bootstrap }} 

在我的forms.py中

  content = forms.CharField(widget=FroalaEditor) 

froala编辑死了吗? 还是我做错了?

如果未设置getCookie函数,则可以按照此页面添加它: https : //docs.djangoproject.com/en/1.9/ref/csrf/

 // using jQuery function getCookie(name) { var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = jQuery.trim(cookies[i]); // Does this cookie string begin with the name we want? if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } 

所以只需将它添加到您的项目中。 还要确保包含所有文件。 也许您错过了已添加此function的文件。