我在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)
2条答案
按热度按时间7lrncoxx1#
你试过运行'manage.py collectstatic'吗?尝试从文档中一步一步地安装它:https://django-ckeditor.readthedocs.io/en/latest/#installation
pcrecxhr2#
我也有同样的问题。在我的例子中,我意识到我没有在我的虚拟环境中安装ckeditor软件包,而只是全局安装。请确保在安装ckeditor软件包时已激活虚拟环境:
在Windows中:
(其中
virt_env
是虚拟环境的名称。)虚拟环境的名称应出现在命令提示符处的圆括号内。然后在那里安装包。