ModuleNotFoundError:没有名为“ckeditor”的模块,我该如何解决?

时间:2021-08-01 17:06:30

标签: python django django-models django-rest-framework django-ckeditor

我在 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)

1 个答案:

答案 0 :(得分:0)

您是否尝试过运行“manage.py collectstatic”? 尝试从文档中逐步安装它: https://django-ckeditor.readthedocs.io/en/latest/#installation