富文本编辑器
富文本编辑器
-
导包
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>