Thursday, 11 August 2022

how to add custom templates in django-ckeditor in django

I am trying to use the Templates feature of the CKEditor in Django and I want to add some custom templates in the list. I've used this approach. I've tried editing

myvenv\Lib\site-packages\ckeditor\static\ckeditor\ckeditor\plugins\templates\templates\default.js

default.js

CKEDITOR.addTemplates("default",{imagesPath:CKEDITOR.getUrl(CKEDITOR.plugins.getPath("templates")+"templates/images/"),templates:[{title:"Welcome Template",image:"template2.gif",description:"A template that you can send to clients as a welcome message.",html:' <h2>Welcome</h2> <p>Hi, <strong> Name here </strong> </p><p>You have recently shown an interest . . . </p>'},]});

but it didn't help, I've tried the collect static command but it didn't help either. I am still seeing the same default three templates. I'm not sure but there is another option of using extra plugins in the settings.py file but I don't know how to use it for this problem.

settings.py

CKEDITOR_UPLOAD_PATH = "file_upload/"

CKEDITOR_CONFIGS = {
    'default': {
        'toolbar':'full',
    },
}

apps

INSTALLED_APPS = [
...,
'ckeditor',
'ckeditor_uploader',
]

urls.py

urlpatterns = [
path('ckeditor/',include('ckeditor_uploader.urls')),]

models.py

class text(models.Model):
    body = RichTextField(blank=True, default="None")

So my question is how to add custom templates in django-ckeditor==6.3.2?



from how to add custom templates in django-ckeditor in django

No comments:

Post a Comment