Ueditor is an open-source Rich Text Editor developed by Baidu. Someone has developed a solution to integrate it into Django (Please stamp it), but the editor cannot be loaded normally in xadmin.
It uses a template to display the ueditor editing interface.
<textarea name={{ UEditor.name }} id=id_{{ UEditor.name }} style="display:inline-block;width:{{ UEditor.width }}px;{{ UEditor.css }}">{{UEditor.value}}</textarea><script type="text/javascript"> var id_{{ UEditor.name }}= new baidu.editor.ui.Editor({ "UEDITOR_HOME_URL":"{{ STATIC_URL }}ueditor/", {% ifnotequal UEditor.toolbars None %}"toolbars":{{ UEditor.toolbars|safe }} ,{% endifnotequal %} "imageUrl":"/ueditor/ImageUp/{{ UEditor.imagePath }}", "imagePath":"{{ MEDIA_URL }}{{ UEditor.imagePath }}", "scrawlUrl":"/ueditor/scrawlUp/{{ UEditor.scrawlPath }}", "scrawlPath":"{{ MEDIA_URL }}{{ UEditor.scrawlPath }}", "imageManagerUrl":"/ueditor/ImageManager/{{ UEditor.imageManagerPath }}", "imageManagerPath":"{{ MEDIA_URL }}{{ UEditor.imageManagerPath }}", "catcherUrl":"/ueditor/RemoteCatchImage/{{ UEditor.imagePath }}", "catcherPath":"{{ MEDIA_URL }}{{ UEditor.imagePath }}", "fileUrl":"/ueditor/FileUp/{{ UEditor.filePath }}", "filePath":"{{ MEDIA_URL }}{{ UEditor.filePath }}", "getMovieUrl":"/ueditor/SearchMovie/" {% ifnotequal UEditor.options ‘‘ %},{{ UEditor.options|safe }}{% endifnotequal %} }); id_{{UEditor.name}}.render(‘id_{{ UEditor.name }}‘); id_{{UEditor.name}}.addListener(‘ready‘,function(){ id_{{UEditor.name}}.setHeight({{ UEditor.height }}); });</script>
I found that this template can be normally loaded in xadmin, So I suspected it was a JS issue. Therefore, I added several alert statements to the script.
id_{{UEditor.name}}.render(‘id_{{ UEditor.name }}‘);
The subsequent Alert does not pop up, but it is because of JS loading problems.
The possible cause is that the loading sequence of static files declared in class media is relatively low, leading to the failure to execute the JS Code of ueditor. Therefore, I added
<script type="text/javascript" src="/static/ueditor/editor_config.js"></script><script type="text/javascript" src="/static/ueditor/editor_all_min.js"></script>
Then ueditor can work normally.