sogeking
sogeking

Reputation: 1276

django-ckeditor: where to store config.js?

I am trying to create my own CKEDITOR.editorConfig. But, so far, I have not managed to make django-ckeditor to use this config.

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:

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. But even though specifying my "uni" toolbar, it just keeps on showing the full one.

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

EDIT

I have tried as well to reference the config js file from ModelAdmin.Media as follows:

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.

Upvotes: 3

Views: 2097

Answers (1)

Patrick
Patrick

Reputation: 2977

I put my file in /static/ckeditor/ckeditor/config.js and it works fine. I'm using the latest djang-ckeditor-updated package

Upvotes: 1

Related Questions