gpt4 book ai didi

由于模板路径问题,django-ckeditor 失败

转载 作者:行者123 更新时间:2023-12-03 15:44:46 25 4
gpt4 key购买 nike

我刚刚通过安装将 django-ckeditor 添加到我的 django 项目中:

pip install django-ckeditor

将其添加到 INSTALLED_APPS ,添加上传路径:
CKEDITOR_UPLOAD_PATH = "ckeditor_uploads/"

运行 manage.py collecstatic只添加了两个文件,并将 URL 添加到我的 url.py :
url(r'^ckeditor/', include('ckeditor_uploader.urls')),

我不是 100% 确定我是否没有遗漏一些东西。

然后我创建了一个非常简单的模型,如下所示:
class BlogPost(models.Model):
title = models.CharField(max_length=255, blank=False, null=False)
body = RichTextField(blank=False, null=False)

当我尝试在管理工具上添加新记录时,出现此错误:

TemplateDoesNotExist at /admin/core/blogpost/add/

ckeditor/widget.html



模板加载器事后分析如下所示:
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)

最后一行之前的行是相关的,它正在尝试加载 ckeditor/widget.html来自 ckeditor_uploader但是 widget.html存在于 ckeditor ,不是 ckeditor_uploader :

enter image description here

任何想法这里发生了什么?

我也试过把这个领域变成 RichTextUploadingField ,但我有同样的错误。

最佳答案

问题是我添加了 ckeditor_uploader而不是 ckeditor到已安装的应用程序。

关于由于模板路径问题,django-ckeditor 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54768236/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com