代码之家  ›  专栏  ›  技术社区  ›  Gozie

Django fontsize tinymce

  •  0
  • Gozie  · 技术社区  · 8 年前

    我想知道是否有其他方法,如果没有,有人能给我一个简单的一步一步的方法来解决它使用内容的css。

    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 回复  |  直到 8 年前
        1
  •  0
  •   DatLicht    8 年前

    要将内容css文件添加到tinymce,必须更改tinymce。初始化对象值以包括您的content\u css。

    在脚本中搜索初始化调用,并向对象添加一行,如本例所示:

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

    ['url 1 here', 'url 2 here', 'your new url here']
    

    body { font-size: 14px; }