【发布时间】:2021-10-07 06:42:13
【问题描述】:
我在 venv 中安装了 ckeditor。在我的设置中,我还在我的设置中添加了 ckeditor 和 ckeditor_uploader。我还添加了 requirements.txt。但似乎没有任何效果。仍然得到the errorModuleNotFoundError: No module named 'ckeditor'
我的终端打印错误
docs | return _bootstrap._gcd_import(name[level:],
package, level)
docs | File "<frozen importlib._bootstrap>", line
1030, in _gcd_import
docs | File "<frozen importlib._bootstrap>", line
1007, in _find_and_load
docs | File "<frozen importlib._bootstrap>", line 984,
in _find_and_load_unlocked
docs | ModuleNotFoundError: No module named 'ckeditor'
docs |
docs | Command exited with exit code: 2
docs | The server will continue serving the build
folder, but the contents being served are no longer in sync
with the documentation sources. Please fix the cause of the
error above or press Ctrl+C to stop the server.
docs | [I 210801 18:55:41 server:335] Serving on
http://0.0.0.0:7000
docs | [I 210801 18:55:41 handlers:62] Start watching
changes
docs | [I 210801 18:55:41 handlers:64] Start detecting
changes
^CGracefully stopping... (press Ctrl+C again to force)
Stopping docs ... done
Stopping postgres ... done
(env) diev@diev:~/test_project$
Here is my setting.py
DJANGO_APPS = [
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.sites",
"django.contrib.messages",
"django.contrib.staticfiles",
# "django.contrib.humanize", # Handy template tags
"django.contrib.admin",
"django.forms",
]
THIRD_PARTY_APPS = [
"crispy_forms",
"allauth",
"allauth.account",
"allauth.socialaccount",
"rest_framework",
"rest_framework.authtoken",
"corsheaders",
'ckeditor',
'ckeditor_uploader',
]
LOCAL_APPS = [
"test_project.users.apps.UsersConfig",
"test_project.core.apps.CoreConfig",
"test_project.cart.apps.CartConfig",
# Your stuff: custom apps go here
]
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
CKEDITOR_JQUERY_URL =
'https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js'
CKEDITOR_UPLOAD_PATH = 'images/'
CKEDITOR_IMAGE_BACKEND = "pillow"
CKEDITOR_CONFIGS = {
'default': {
'toolbar': None,
},
}
urls.py
urlpatterns = [
path('_ckeditor/', include('ckeditor_uploader.urls')),
]
models.py
from ckeditor_uploader.fields import RichTextUploadingField
class About(models.Model):
name = models.CharField(max_length=50)
about_text = RichTextUploadingField()
def __str__(self):
return str(self.name)
【问题讨论】:
-
ckeditor和ckeditor_uploader在您的设置中位于THIRD_PARTY_APPS。你是如何加入INSTALLED_APPS..??请在问题中添加INSTALLED_APPS...?? -
谢谢,我正在使用 cookiecutter-django 配置,您可以查看我编辑过的问题
-
如果您能向我们展示错误是如何出现的,那将会很有用:如果您在终端中启动您的应用程序,您是否可以复制终端的内容(至少从您运行的命令到错误本身)?或者,如果您从 IDE 启动它,则可能是出现错误时 IDE 的屏幕截图。
-
感谢,我已经添加了屏幕截图以及终端中的打印错误
-
ckeditor 是否存在于requirement.txt 中?
标签: python django django-models django-rest-framework django-ckeditor