2017-09-14 10 views
0

私はfrog WYSIWYGを私のdjangoプロジェクトにインストールしようとしていますが、ドキュメントに記載されているようにすべて準備しました しかし、コンテンツフィールドはまだテキストフィールド です。 ?froala djangoはテンプレートでは機能しません

私のコード 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') 

テンプレート

{% 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> 

ノート私の見解で

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

と私はとのトラブルを抱えていることjqueryのクッキー エラー:

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) 
+0

@Awinのおかげで、これは答えです: [django-froala-editorを使用すると、管理ページのエディタはポストページで動作しません。 https://stackoverflow.com/questions/34941170/using-django-froala-editor-the-editor-works-in-admin-page-wont-work-in-post-pa) – a7me3D

答えて

0

あなたはファイルがロードされているかどうかを確認するには、ブラウザでチェックしましたか?静的ファイルは/static/...{{ STATIC_URL }}...の両方で参照していますが、インポートした{% static '...' %} template tagを使用することをおすすめします。それは次のようになります。そのために

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

は、動作するようにあなたがまだの場合は、プロジェクトの設定でDjangoのstaticfilesアプリを設定する必要があります。 The Django docsは、その部分を並べ替えるのに役立ちます。

+0

「froala_editor/css」のようなファイルがあります/froala-django.css 'と' froala_editor/js/froala-django.js 'はディレクトリ内にも見つからず、staticfilesパスが正しくインストールされています – a7me3D

+0

これらのファイルは、froala_editor/widgets.pyで参照されています – a7me3D

+0

あなたのコメントi解決策を見つけた – a7me3D

関連する問題