富文本编辑器

富文本编辑器

  • 导包

    pip install tinymce
    
  • 注册

    INSTALLED_APPS = [
        'tinymce'
    ]
    
  • 路由

    urlpatterns = [
        path('tinymce/',views.TinymceView.as_view(),name='tinymce'),
    ]
    
  • 视图

    class TinymceView(APIView):
        def get(self,request):
            return render(request,'tinymce.html')
    
  • 模版

    <!DOCTYPE html>
    <html>
    <head>
        <script type="text/javascript" src='/static/tiny_mce/tiny_mce.js'></script>
        <script type="text/javascript">
            tinyMCE.init({
                'mode':'textareas',
                'theme':'advanced',
                'width':800,
                'height':200
            });
        </script>
    </head>
    <body>
        <form method="post" action="{%raw%}{% url 'demo2' %}{%endraw%}">
            <input type="text" name="hname">
            <br>
            <textarea name='hcontent'>主体</textarea>
            <br>
            <input type="submit" value="提交">
        </form>
    </body>
    </html>
    
posted @ 2019-12-18 20:46  巫小诗  阅读(468)  评论(0编辑  收藏  举报