I just added django-ckeditor to my django project by installing it:
pip install django-ckeditor
adding it to INSTALLED_APPS
, adding the upload path:
CKEDITOR_UPLOAD_PATH = "ckeditor_uploads/"
run manage.py collecstatic
which only added two files, and adding the URLs to my url.py
:
url(r'^ckeditor/', include('ckeditor_uploader.urls')),
I'm not 100% sure if I'm not missing something there.
Then I created a very simple model that looks like this:
class BlogPost(models.Model):
title = models.CharField(max_length=255, blank=False, null=False)
body = RichTextField(blank=False, null=False)
When I try to add a new record on the admin tool I get this error:
TemplateDoesNotExist at /admin/core/blogpost/add/
ckeditor/widget.html
The template loader postmortem looks like this:
Template-loader postmortem
Django tried loading these templates, in this order:
Using engine django:
django.template.loaders.filesystem.Loader: C:\Users\pupeno\projectx\venv\lib\site-packages\django\forms\templates\ckeditor\widget.html (Source does not exist)
django.template.loaders.app_directories.Loader: C:\Users\pupeno\projectx\core\templates\ckeditor\widget.html (Source does not exist)
django.template.loaders.app_directories.Loader: C:\Users\pupeno\projectx\venv\lib\site-packages\django\contrib\admin\templates\ckeditor\widget.html (Source does not exist)
django.template.loaders.app_directories.Loader: C:\Users\pupeno\projectx\venv\lib\site-packages\django\contrib\auth\templates\ckeditor\widget.html (Source does not exist)
django.template.loaders.app_directories.Loader: C:\Users\pupeno\projectx\venv\lib\site-packages\rest_framework\templates\ckeditor\widget.html (Source does not exist)
django.template.loaders.app_directories.Loader: C:\Users\pupeno\projectx\venv\lib\site-packages\reversion\templates\ckeditor\widget.html (Source does not exist)
django.template.loaders.app_directories.Loader: C:\Users\pupeno\projectx\venv\lib\site-packages\colorfield\templates\ckeditor\widget.html (Source does not exist)
django.template.loaders.app_directories.Loader: C:\Users\pupeno\projectx\venv\lib\site-packages\ckeditor_uploader\templates\ckeditor\widget.html (Source does not exist)
django.template.loaders.app_directories.Loader: C:\Users\pupeno\projectx\venv\lib\site-packages\django_extensions\templates\ckeditor\widget.html (Source does not exist)
The line before the last one is relevant, it's trying to load ckeditor/widget.html
from ckeditor_uploader
but widget.html
is present in ckeditor
, not ckeditor_uploader
:
Any ideas what's going on here?
I also tried turning the field into a RichTextUploadingField
, but I've got the same error.
The problem was that I added ckeditor_uploader
and not ckeditor
to the installed apps.
Even I faced the same issue. Please follow my steps. it will work for me as well as many of my friends also.
Remember it will also work for production level as i hosted many django application in online.
pip install django-ckeditor
after
step 1: write inside models.py
from ckeditor.fields import RichTextField
class BlogPost(models.Model):
title = models.CharField(max_length=255, blank=False, null=False)
body = RichTextField(blank=False, null=False)
step 2: run command python manage.py makemigrations
step 3: run command python manage.py migrate
step 4: write in admin.py
from .models import BlogPost
admin.site.register(BlogPost)
step 4: I added "ckeditor" in installed_apps of settings.py.
step 5: run command python manage.py collectstatic
It will ask you to overrite Existing files and type yes
make sure your directory structure look like
step 6: Copy ckeditor folder in root static folder where your control panel looks for
In my case i have to copy ckditor folder in another called public_html
I coppied ckeditor folder in public_html/static/
All done
You need both apps in INSTALLED_APPS:
INSTALLED_APPS = [
...
'ckeditor',
'ckeditor_uploader'
...
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With