简体   繁体   English

django-ckeditor:在哪里存储config.js?

[英]django-ckeditor: where to store config.js?

I am trying to create my own CKEDITOR.editorConfig. 我正在尝试创建自己的CKEDITOR.editorConfig。 But, so far, I have not managed to make django-ckeditor to use this config. 但是,到目前为止,我还没有设法让django-ckeditor使用这个配置。

This is my structure: 这是我的结构:

.
├── cms
│   ├── admin.py
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── media
│   │   ├── ck_uploads
│   │   └ ...
│   ├── settings.py
│   ├── static
│   │   ├── ckeditor
│   │   │   └── ckeditor
│   │   │       ├── ckeditor
│   │   │       │   └── config.js
│   │   │       └── config.js
│   │   └── ...
│   ├── templates
│   │   └── ...
│   └── ...
└── ...

In my config.js (both, but none of those locations seem to be correct) I have created a small editorConfig, just to check that it's working: 在我的config.js中(两者,但这些位置似乎都不正确)我创建了一个小的editorConfig,只是为了检查它是否正常工作:

CKEDITOR.editorConfig = function( config ) {
    // Define changes to default configuration here. For example:
    // config.language = 'fr';
    // config.uiColor = '#AADC6E';
    config.toolbar_Uni =
    [
        [ 'Source', '-', 'Bold', 'Italic' ]
    ];
    config.toolbar = 'Uni';
};

Finally from my settings.py I have added some initial configuration. 最后从我的settings.py中添加了一些初始配置。 But even though specifying my "uni" toolbar, it just keeps on showing the full one. 但即使指定我的“uni”工具栏,它也会继续显示完整的工具栏。

PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
MEDIA_ROOT = os.path.join(PROJECT_PATH, "media")
STATIC_ROOT = os.path.join(PROJECT_PATH, "static")
CKEDITOR_RESTRICT_BY_USER = True
CKEDITOR_UPLOAD_PATH = os.path.join(MEDIA_ROOT, 'ck_uploads')
CKEDITOR_CONFIGS = {
    'default': {
        'width': '100%',
        'toolbar': 'Uni',
    },
    'basic': {
        'width': '100%',
        'toolbar': 'Basic',
    }
}

Any suggestion please? 有什么建议吗? Thanks! 谢谢!

.Soge .Soge

EDIT 编辑

I have tried as well to reference the config js file from ModelAdmin.Media as follows: 我也试过从ModelAdmin.Media引用config js文件,如下所示:

class MyAdmin(ModelAdmin):

    class Media:
        js = ( settings.STATIC_URL + 'js/ckeditor-config.js',)

Then my static directory structure would remain something like this: 然后我的静态目录结构将保持这样:

.
├── cms
│   ├── static
│   │   ├── ckeditor-config.js
│   │   └── ...
│   └── ...
└── ...

Still no success. 仍然没有成功。

I put my file in /static/ckeditor/ckeditor/config.js and it works fine. 我把我的文件放在/static/ckeditor/ckeditor/config.js ,它运行正常。 I'm using the latest djang-ckeditor-updated package 我正在使用最新的djang-ckeditor-updated

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM