我开始在一家公司学习网络开发,并负责在 cookiecutter django 中制作一个简单的应用程序,然后将 django-cms 集成到其中。
我使用 django cookie-cutter 启动了一个项目,然后按照以下指南将 django-cms 集成到项目中:
https://github.com/pydanny/cookiecutter-django
http://docs.django-cms.org/en/latest/how_to/install.html
在经历了最初的一些麻烦之后,我设法让它继续运行。 之后,下一步是将我的“投票”应用程序添加到项目中,并将 Django CMS 集成到其中。
为此,我遵循了本教程:
我设法一直走到最后一个链接的末尾,然后在第 6 步,发生了这种情况。
每次我尝试从我的站点删除插件,或者当我在 CMS 工具栏上单击创建时,我都会收到此错误(注意:如果我登录/admin,我可以创建页面,但不能通过 cms实际网站上的菜单栏):
The form could not be loaded. Please check that the server is running correctly.
服务器一切正常。那里没有错误。
在控制台中:
Refused to display 'http://127.0.0.1:8000/cms_wizard/create/?page=5&language=en&edit&cms_path=/home/?edit&language=en&structure' in a frame because it set 'X-Frame-Options' to 'deny'.
bundle.toolbar.min.js:1 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
这两天我一直在谷歌搜索,我就是想不通。 任何帮助将不胜感激!
我已经在我的 github 上推送了我更改的文件,如果您需要任何其他信息,请告诉我,我会立即包含它。
https://github.com/sandilukez/cms-django-cookie
我尝试了所有我能在网上找到的东西,但没有成功!
最佳答案
上面的答案很接近,至少是问题所在,但答案 X_FRAME_OPTIONS = "ALLOWALL"
可能会导致安全问题。
正如 django 文档中提到的那样
Modern browsers honor the X-Frame-Options HTTP header that indicates whether or not a resource is allowed to load within a frame or iframe. If the response contains the header with a value of SAMEORIGIN then the browser will only load the resource in a frame if the request originated from the same site.
为了使 django cms 能够在网站内打开 iframe,我们应该在我们的设置中放置 X_FRAME_OPTIONS = 'SAMEORIGIN'
。这样我们就不允许其他网站将我们的网站包含为 iframe 但让 django cms 正常工作。
有关详细信息,请参阅相关文档:https://docs.djangoproject.com/en/3.1/ref/clickjacking/
关于Django CMS - cookie cutter : The form could not be loaded. 请检查服务器是否正常运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57909645/