Search code examples
djangockeditor

How to override div wrapper class of ckeditor Django?


Cant find a way to override ckeditor base wrapper div class. By default it has html template like this: https://i.sstatic.net/8gZUJ.png

Is there a way to change class name "django-ckeditor-widget" to something else? Was trying to do:

class PostAdminForm(forms.ModelForm):
content = forms.CharField(widget=CKEditorWidget(), attrs={'class': 'MyCustomClass})
class Meta:
    model = Post

But this dosnt work


Solution

  • The widget uses a simple template at "templates/ckeditor/widget.html" (see the source). So create your own by that name in your app to override it (this requires your app appear before django-ckeditor in INSTALLED_APPS).