Integrate ueditor in Django xadmin

Source: Internet
Author: User

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.