有没有一种方法可以在django admin的编辑器中使用自定义模板?

时间:2019-08-20 15:04:02

标签: django ckeditor django-ckeditor

我在将自定义模板文件加载到位于django admin中的编辑器中时遇到问题。

我只是简单地将文件路径放入CKEDITOR_CONFIGS中,就像这样:

CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': [
            [...]
        ],
        'templates_files': [
            /path/to/template/template.js'
        ],
        'templates': 'template'
    }
}
CKEDITOR.addTemplates( 'template', {
    templates: [ {
        title: 'BLEBELLBELBE',
        description: 'A template that defines two columns, each one with a title, and some text.',
        html: '<table cellspacing="0" cellpadding="0" style="width:100%" border="0">' +
            '<tr>' +
                '<td style="width:50%">' +
                    '<h3>Title 1</h3>' +
                '</td>' +
                '<td></td>' +
                '<td style="width:50%">' +
                    '<h3>Title 2</h3>' +
                '</td>' +
            '</tr>' +
            '<tr>' +
                '<td>' +
                    'Text 1' +
                '</td>' +
                '<td></td>' +
                '<td>' +
                    'Text 2' +
                '</td>' +
            '</tr>' +
            '</table>' +
            '<p>' +
            'More text goes here.' +
            '</p>'
    } ]
} );

Ckeditor忽略该文件,或者只是在浏览器控制台上抛出错误而无法加载该文件。我在做什么错了?

0 个答案:

没有答案