2017-07-31 5 views
0

私のプロジェクトでdjango tinymceを使用しようとしていますが、フォントが小さすぎます。私はそれをgoogledし、私はcontent_cssを使用するつもりですが、正確にこれを行う必要があるかどうかについてのステップ・アプローチによる適切なステップがないことを学びました。Django fontsize tinymce

私は別の方法があるかどうか疑問に思っています。もしそうでなければ、誰かが私にcontent_cssを使用して解決するための簡単なステップ・アプローチを与えることができますか? は以下のTinyMCEするために、コンテンツのCSSファイルを追加するにはforms.py

class PostForm(forms.ModelForm): 
text = forms.CharField(help_text='Enter your Post here', widget=TinyMCE(attrs={'cols': 80, 'rows': 10})) 
name = forms.CharField(widget=forms.HiddenInput(), initial='User') 
created_on = forms.DateTimeField(widget=forms.HiddenInput(), initial=timezone.now()) 


class Meta: 
    model = Post 
    fields = ('title', 'text',) 

{% extends 'blog/base.html' %} 
{% load staticfiles %} 

    {% block body_block %} 
    <!-- <h1>TinyMCE Quick Start Guide</h1> 
    <form method='post'> 
     <textarea id = 'mytextarea'>Hello, World!</textarea> 
    </form> --> 
    {% if post %} 
     <div class="single"> 
      <div class="container"> 
        <div class="col-md-8 single-main"> 
         <div class="single-grid"> 
          <h4><a href="{% url 'blog:detail' post.slug %}">{{ post.title|safe }}</a></h4> 
          <img src="{% static 'images/post1.jpg' %}" alt=""/> 
          <p>{{ post.text|safe }}</p> 
         </div> 
         <div class="comments"> 
          <h2><u>Comments</u></h2> 
           {% if comments %} 
            {% for comment in comments %} 
            <h3>~{{ comment.commenter.first_name|title}} {{comment.commenter.last_name|title }}</h3> 
            <ul> 
             <li> 
               {{ comment.text|safe }} 
             </</li><br> 
            </ul> 
            <span class="hidden-xs"style="margin-left:70%;, font-family:Arial">Published: {{ comment.created_on }}</span > 
            {% if comment.commenter == request.user or user.is_superuser %} 
              <a href="{% url 'blog:delete_comment' comment.id %}"><button style="margin-left:90%;,line-height: .9;color: red;, font-family:Arial;" type="button" name="button">Delete</button></a> 
            {% endif %} 

            {% endfor %} 
           {% else %} 
            No comments available 
           {% endif %} 
         </div> 
         <div class="content-form"> 
          <h3>Leave a comment</h3> 
          {% if user.is_authenticated %} 
           <form id="comment_form" action="{% url 'blog:detail' post.slug %}" method="post"> 
            {% csrf_token %} 
             {% for hidden in form.hidden_fields %} 
               {{ hidden }} 
             {% endfor %} 
             {% for field in form.visible_fields %} 
              {{ field.errors }} 

              {{ field }}<br/><br/> 
             {% endfor %} 
             <input class="btn btn-primary" type="submit" name="submit" value="submit"> 
           </form> 
           {% else %} 
           <a href="{% url 'blog:handle_login' %}">You must be logged in to comment</a> 
           {% endif %} 
           </div> 



         <ul class="comment-list " > 
           <h5 class="post-author_head">Written by <a href="#" title="Posts by admin" rel="author">{{ post.author.first_name|title }} {{ post.author.last_name|title }}</a></h5> 
           <li><img src="{% static 'images/avatar.png' %}" class="img-responsive" alt=""> 
           <div class="desc"> 
           <p>View all posts by: <a href="#" title="Posts by admin" rel="author">{{ post.author.first_name|title }} {{ post.author.last_name|title }}</a></p> 
           </div> 
           <div class="clearfix"></div> 
           </li> 
          </ul> 
        </div> 
        <div class="col-md-4 side-content"> 
         <div class="recent"> 
         <h3>RECENT POSTS</h3> 
         {% if recent_posts %} 
         <ul> 
          {% for post in recent_posts %} 
         <li><a href="{% url 'blog:detail' post.slug %}">{{post.title|title }}</a></li> 
         {% endfor %} 
         </ul> 
         {% else %} 
        <li><a href="#">No post has been posted</a></li> 
         {% endif %} 
        </div> 
        <div class="comments"> 
         <h3>RECENT COMMENTS</h3> 
         {% if recent_comments %} 
         <ul> 
          {% for comment in recent_comments %} 
         <li><a href="{% url 'blog:detail' comment.post.slug %}">{{comment.commenter|title}} on {{comment.post|title}}</a></li> 
          {% endfor %} 
         </ul> 
         {% else %} 
         <li><a href="#">No comments at the moment</a></li> 
         {% endif %} 
        </div> 
        <div class="clearfix"></div> 
        <div class="archives"> 
         <h3>ARCHIVES</h3> 
         <ul> 
         <li><a href="#">October 2013</a></li> 
         <li><a href="#">September 2013</a></li> 
         <li><a href="#">August 2013</a></li> 
         <li><a href="#">July 2013</a></li> 
         </ul> 
        </div> 
        <div class="clearfix"></div> 
        </div> 

         <div class="clearfix"></div> 
        </div> 
       </div> 
       {% if comment.commenter == request.user or user.is_superuser %} 
        <a href="{% url 'blog:delete_post' post.id %}"><button style="margin-left:90%;,line-height: .9;color: red;, font-family:Arial;" type="button" name="button">Delete Post</button></a> 
        <a href="{% url 'blog:edit_post' post.id %}"><button style="margin-left:90%;,line-height: .9;color: red;, font-family:Arial;" type="button" name="button">Edit Post</button></a> 
       {% endif %} 
     {% else %} 
     asadsh 
     {% endif %} 
     {% endblock %} 
+1

、ご希望のフォントサイズを設定することができ、私のコードを投稿テキストを出す。 – hansTheFranz

+0

@hansTheFranz私はdetail.htmlを追加しました – Gozie

+0

@hansTheFranzそれはテキストが表示されている場所です – Gozie

答えて

0

で、あなたのcontent_cssを含むようにtinymce.initオブジェクトの値を変更する必要があります。

スクリプトで初期化呼び出しを検索すると、この例のように、あなたのオブジェクトに行を追加します。

tinymce.init({ 
... 
      content_css: [ 
       '//example.com/js/your-css-here.css' 
      ], 
... 
}); 

をcontent_css一部がすでに存在する場合は、単にアレイにURLを追加し、すなわち

カスタムCSSファイルで
['url 1 here', 'url 2 here', 'your new url here'] 

、あなたは今、すなわち

body { font-size: 14px; } 
+0

content.cssファイルの場所はわかりません。それはローカルファイルですか?この例で使用したのはURLです。 – Gozie

+0

content_cssは、生成されたコードに統合される追加のCSSファイルを指定します(たとえば、エディタ内で使用およびプレビューするいくつかのCSSクラスを定義している場合など)。通常、ファイルはサーバーに格納されますが、相対的にリンクすることもできます。私の例では、ファイルはネット上のサーバーに保存され、エディタと同じプロトコルを使用します。相対パスを指定することもできます(例: '/directory/anotherdir/my.css' – DatLicht

関連する問題