Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django 2.0.1与CKEditor不兼容';无法在管理页面上工作_Python_Django_Static_Ckeditor - Fatal编程技术网

Python Django 2.0.1与CKEditor不兼容';无法在管理页面上工作

Python Django 2.0.1与CKEditor不兼容';无法在管理页面上工作,python,django,static,ckeditor,Python,Django,Static,Ckeditor,我试图安装CKeditor,但找不到方法。 我试过的步骤 pip安装django ckeditor 将“ckeditor”添加到已安装的应用程序设置中 运行collectstatic CKEDITOR_BASEPATH=“/static/CKEDITOR/CKEDITOR”到我的设置 及 当我要求管理员页面提供合适的型号时,我只能得到空白的白色页面。 终端上没有错误。CKeditor文件返回302 HTTP。 我的管理页面截图 奇怪的是,我能在DOM上看到相关的编辑器内容。 我遗漏了什么吗

我试图安装CKeditor,但找不到方法。

我试过的步骤

  • pip安装django ckeditor
  • 将“ckeditor”添加到已安装的应用程序设置中
  • 运行collectstatic
  • CKEDITOR_BASEPATH=“/static/CKEDITOR/CKEDITOR”到我的设置

当我要求管理员页面提供合适的型号时,我只能得到空白的白色页面。 终端上没有错误。CKeditor文件返回302 HTTP。

我的管理页面截图

奇怪的是,我能在DOM上看到相关的编辑器内容。
我遗漏了什么吗?

我不知道你是否明白了这一点。我花了三个小时的大部分时间让它为我工作

我看到有一个404:

Quit the server with CTRL-BREAK.
[27/May/2018 13:50:02] "GET /admin/projects/blogproject/add/ HTTP/1.1" 200 9674
[27/May/2018 13:50:02] "GET /admin/jsi18n/ HTTP/1.1" 200 3185
[27/May/2018 13:50:04] "GET /static/ckeditor/ckeditorconfig.js?t=H8DA HTTP/1.1" 404 1709
[27/May/2018 13:50:05] "GET /static/ckeditor/ckeditorskins/moono-lisa/editor.css?t=H8DA HTTP/1.1" 404 1763
[27/May/2018 13:50:05] "GET /static/ckeditor/ckeditorlang/en.js?t=H8DA HTTP/1.1" 404 1712
[27/May/2018 13:52:35] "GET /admin/projects/blogproject/add/ HTTP/1.1" 200 9674
[27/May/2018 13:52:35] "GET /admin/jsi18n/ HTTP/1.1" 200 3185
[27/May/2018 13:52:37] "GET /static/ckeditor/ckeditorconfig.js?t=H8DA HTTP/1.1" 404 1709
[27/May/2018 13:52:38] "GET /static/ckeditor/ckeditorskins/moono-lisa/editor.css?t=H8DA HTTP/1.1" 404 1763
[27/May/2018 13:52:38] "GET /static/ckeditor/ckeditorlang/en.js?t=H8DA HTTP/1.1" 404 1712
因此,将这一行从:

CKEDITOR_BASEPATH = "/static/ckeditor/ckeditor"
收件人:(刚在末尾加了一条斜线)


该小部件现在可以在管理员中为我提供。

我不知道您是否了解了这一点。我花了三个小时的大部分时间让它为我工作

我看到有一个404:

Quit the server with CTRL-BREAK.
[27/May/2018 13:50:02] "GET /admin/projects/blogproject/add/ HTTP/1.1" 200 9674
[27/May/2018 13:50:02] "GET /admin/jsi18n/ HTTP/1.1" 200 3185
[27/May/2018 13:50:04] "GET /static/ckeditor/ckeditorconfig.js?t=H8DA HTTP/1.1" 404 1709
[27/May/2018 13:50:05] "GET /static/ckeditor/ckeditorskins/moono-lisa/editor.css?t=H8DA HTTP/1.1" 404 1763
[27/May/2018 13:50:05] "GET /static/ckeditor/ckeditorlang/en.js?t=H8DA HTTP/1.1" 404 1712
[27/May/2018 13:52:35] "GET /admin/projects/blogproject/add/ HTTP/1.1" 200 9674
[27/May/2018 13:52:35] "GET /admin/jsi18n/ HTTP/1.1" 200 3185
[27/May/2018 13:52:37] "GET /static/ckeditor/ckeditorconfig.js?t=H8DA HTTP/1.1" 404 1709
[27/May/2018 13:52:38] "GET /static/ckeditor/ckeditorskins/moono-lisa/editor.css?t=H8DA HTTP/1.1" 404 1763
[27/May/2018 13:52:38] "GET /static/ckeditor/ckeditorlang/en.js?t=H8DA HTTP/1.1" 404 1712
因此,将这一行从:

CKEDITOR_BASEPATH = "/static/ckeditor/ckeditor"
收件人:(刚在末尾加了一条斜线)


这个小部件现在可以在Admin中为我提供。

问题在于静态文件的位置。实际上,服务器找不到呈现ckeditor小部件所需的静态文件

简单的解决方案


您需要将ckeditor包中静态文件夹的内容上载到项目的静态文件夹中(尽管是手动的!)。

问题在于静态文件的位置。实际上,服务器找不到呈现ckeditor小部件所需的静态文件

简单的解决方案


您需要将ckeditor包中静态文件夹的内容上载到项目的静态文件夹中(尽管是手动的!)。

我遇到了这个问题,结果我在我的
ckeditor\u BASEPATH中使用了
static\u ROOT
,因此重定向到:

staticfiles/ckeditor/ckeditor
(即服务器或硬盘上的静态文件夹,您可以在其中使用collectstatic进行收集)

这与浏览器无关。我通过使用
STATIC\u URL
解决了这个问题,并给出了地址:


/static/ckeditor/ckeditor/
(即url)

我遇到了这个问题,原来我在
ckeditor\u BASEPATH中使用了
static\u ROOT
,因此重定向到:

staticfiles/ckeditor/ckeditor
(即服务器或硬盘上的静态文件夹,您可以在其中使用collectstatic进行收集)

这与浏览器无关。我通过使用
STATIC\u URL
解决了这个问题,并给出了地址:


/static/ckeditor/ckeditor/
(即url)

我认为您应该遵循以下步骤:

pip install django-ckeditor
设置.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sitemaps',
    'app1',
    'app2',
    'crispy_forms',
    'ckeditor_uploader',
    'ckeditor',
]

...

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static")
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), ]


MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'media')

CKEDITOR_CONFIGS = {
    "default": {
        "removePlugins": "stylesheetparser",
        "allowedContent":True,
        "width": "100%",
    }
}

CKEDITOR_BASEPATH = "/static/ckeditor/ckeditor/"
CKEDITOR_UPLOAD_PATH = "uploads/"
CKEDITOR_FILENAME_GENERATOR = 'utils.get_filename'
X_FRAME_OPTIONS = 'SAMEORIGIN'
然后,您应该在终端中运行以下代码:

python manage.py collectstatic
我的django管理员ss:


如果您在项目中进行了模型和模板设置,则不会出现错误。

我认为您应该遵循以下步骤:

pip install django-ckeditor
设置.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sitemaps',
    'app1',
    'app2',
    'crispy_forms',
    'ckeditor_uploader',
    'ckeditor',
]

...

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static")
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), ]


MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'media')

CKEDITOR_CONFIGS = {
    "default": {
        "removePlugins": "stylesheetparser",
        "allowedContent":True,
        "width": "100%",
    }
}

CKEDITOR_BASEPATH = "/static/ckeditor/ckeditor/"
CKEDITOR_UPLOAD_PATH = "uploads/"
CKEDITOR_FILENAME_GENERATOR = 'utils.get_filename'
X_FRAME_OPTIONS = 'SAMEORIGIN'
然后,您应该在终端中运行以下代码:

python manage.py collectstatic
我的django管理员ss:

如果在项目中进行了模型和样板设置,则不会出现错误