[英]Pop-ups in django-tinymce editor showing 404 error
我已经安装了django-tinymce,可以在我网站的admin部分中使用文本字段。 该编辑器运行良好,尽管效果不理想,因为每当我尝试插入图像,链接,符号等时(即,每当出现弹出窗口时),编辑器都会打开404 Not found窗口,而不是实际的窗口小部件形式。
我尝试添加
document.domain = 'my_site.com';
到tiny_mce_popup.js 。 没有改变。
有趣的是,应该在弹出窗口中打开的* .htm文件存储在目录{{MEDIA_URL}} js / tiny_mce / themes / advanced /中(如前所述,服务器无法打开他们)。 但是,如果我尝试在浏览器中打开同一目录中的其他文件(例如{{MEDIA_URL}} js / tiny_mce / themes / advanced / editor_template.js或{{MEDIA_URL}} js / tiny_mce / themes / advanced / img / flash .gif),一切正常-文件显示无任何错误。
另外,在本地服务器上,一切都可以正常工作-仅在部署后才遇到问题。
项目的urls.py :
urlpatterns = patterns('',
#...
url(r'^tinymce/', include('tinymce.urls')),
#...
)
TinyMCE的urls.py :
from django.conf.urls.defaults import *
urlpatterns = patterns('tinymce.views',
url(r'^js/textareas/(?P<name>.+)/$', 'textareas_js', name='tinymce-js'),
url(r'^js/textareas/(?P<name>.+)/(?P<lang>.*)$', 'textareas_js', name='tinymce-js-lang'),
url(r'^spellchecker/$', 'spell_check'),
url(r'^flatpages_link_list/$', 'flatpages_link_list'),
url(r'^compressor/$', 'compressor', name='tinymce-compressor'),
url(r'^filebrowser/$', 'filebrowser', name='tinymce-filebrowser'),
url(r'^preview/(?P<name>.+)/$', 'preview', name='tinymce-preview'),
)
TinyMCE的settings.py :
import os
from django.conf import settings
DEFAULT_CONFIG = getattr(settings, 'TINYMCE_DEFAULT_CONFIG',
{'theme': "advanced", 'relative_urls': False})
USE_SPELLCHECKER = getattr(settings, 'TINYMCE_SPELLCHECKER', False)
USE_COMPRESSOR = getattr(settings, 'TINYMCE_COMPRESSOR', False)
USE_FILEBROWSER = getattr(settings, 'TINYMCE_FILEBROWSER',
'filebrowser' in settings.INSTALLED_APPS)
JS_URL = getattr(settings, 'TINYMCE_JS_URL',
'%sjs/tiny_mce/tiny_mce.js' % settings.MEDIA_URL)
JS_ROOT = getattr(settings, 'TINYMCE_JS_ROOT',
os.path.join(settings.MEDIA_ROOT, 'js/tiny_mce'))
JS_BASE_URL = JS_URL[:JS_URL.rfind('/')]
那么,如何使django-tinymce的弹出窗口起作用? 在此先感谢您的帮助!
编辑:找到解决方案。 原来我的托管服务提供商未在允许的静态文件扩展名列表中包含htm(l) 。 现在一切正常。
它可以在开发服务器下运行,但不能运行,这一事实使我认为您尚未在apache conf中正确设置媒体根目录。 开发服务器会自动为您的媒体和静态文件提供服务,但是对于您的实时部署,您需要使用相关路径添加媒体和静态别名。
vhost.conf:
<VirtualHost *:80>
# Your setup for your main site url, then add the below to allow access
# to the media and static roots
Alias /media/ "/path/to/myproject/media/"
<Directory "/path/to/myproject/media/">
Order deny,allow
Allow from all
</Directory>
Alias /static/ "/path/to/myproject/static/"
<Directory "/path/to/myproject/static/">
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.