Search code examples
pythondjangowysiwygfroala

froala django doesn't work in template


i'm trying to use froala WYSIWYG in my django project i installed and prepared everything as it is mention in the docs but the content field still displayed as text field so any solution ??

my code forms.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')

template

{% load static %}
{% load crispy_forms_tags %}
        <html>
        <head>
        <title></title>
        <link rel="stylesheet" type="text/css" href="/static/bootstrap-3.3.7-dist/css/bootstrap.min.css">
                <link rel="stylesheet" type="text/css" href="/static/font-awesome/css/font-awesome.min.css">
                <link rel="stylesheet" type="text/css" href="/static/font-awesome/css/font-awesome.css">
    <link href="{{STATIC_URL}}froala_editor/css/font-awesome.min.css" type="text/css" media="all" rel="stylesheet" />
    <link href="{{STATIC_URL}}froala_editor/css/froala_editor.min.css" type="text/css" media="all" rel="stylesheet" />
    <script type="text/javascript" src="{{STATIC_URL}}froala_editor/js/froala_editor.min.js"></script
    </head>
    <body>
<form method="POST" class="padding" enctype="multipart/form-data">
        {% csrf_token %}
        {{ editor|crispy }}        
  </form>
    </body>

        </html>

note that

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

in my views

and i'm having trouble with jquery cookies error:

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)

Solution

  • i found this answer Using django-froala-editor, the editor works in admin page won't work in post page the problem was in Jquery I replaced the main Jquery file before Froala scripts