所以我试图让文件浏览器在django中使用tinymce。 Evrything很好用tinymce,漂亮的花哨文本编辑器。当我尝试打开文件浏览器时,我在/ admin / filebrowser / browse /中获得了ImproperlyConfigured 找到上传文件夹时出错(MEDIA_ROOT + DIRECTORY)。也许它不存在?我没有在控制台中得到任何错误,只要我可以告诉它应该寻找/ media / filebrowser /肯定存在
python manage.py test filebrowser give me this:
FAIL: test_directory (filebrowser.tests.settings.SettingsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/nada/costumeshoppe/filebrowser/tests/settings.py", line 29, in test_directory
self.assertEqual(os.path.exists(os.path.join(MEDIA_ROOT,DIRECTORY)), 1)
AssertionError:False!= 1
我的设置:
STATIC_ROOT = ROOT_PATH +'/public/static/'
STATIC_URL = '/static/'
MEDIA_ROOT = ROOT_PATH + '/public/media/'
MEDIA_URL = '/media/'
TINYMCE_JS_ROOT = '/static/tiny_mce/'
TINYMCE_JS_URL = os.path.join(STATIC_URL, "tiny_mce/tiny_mce_src.js")
TINYMCE_DEFAULT_CONFIG = {
'plugins': "table,spellchecker,paste,searchreplace,styles",
'theme': "advanced",
}
我的网址:
if settings.DEBUG:
urlpatterns += patterns('',
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT,})
)
urlpatterns += staticfiles_urlpatterns()
我正在调试模式下运行,不知道这是不是问题,确实有一个奇怪的问题,我可以使用静态url加载静态文件,但它们必须在媒体目录中,尽管文件浏览器静态文件位于我的静态文件位置,修复了一些安装问题,但将这些文件放在媒体位置也没有改变任何内容。有什么想法可以让它发挥作用吗?
答案 0 :(得分:12)
默认FILEBROWSER_DIRECTORY是“上传”,因此您应该检查'/ media / uploads'是否存在
答案 1 :(得分:3)
DIRECTORY
在filebrowser.settings中设置为上传/此媒体根目录中是否存在此文件夹?
可以使用FILEBROWSER_DIRECTORY
答案 2 :(得分:0)
是的,您应该添加新的目录名称“uploads”。
在它的官方DOC中,你可以找到anwser。
https://django-filebrowser.readthedocs.org/en/3.5.2/settings.html#directory-relative-to-media-root
DIRECTORY = getattr(settings, "FILEBROWSER_DIRECTORY", 'uploads/')
答案 3 :(得分:0)
如果有人遇到同样的问题,请read this post。它对我有用。
摘录子孙后代的内容:
如果您想使用tinymce小部件编辑zinnia博客文章,您可能还想使用filebrowser使用您的media django媒体文件夹插入/编辑图像。这是行不通的 开箱即用。
...
- 安装zinnia
- 安装filebrowser
- 安装django-tinymce
使用内容
创建自己的文件admin/zinnia/entry/tinymce_textareas.js
tinyMCE.init({
file_browser_callback: "djangoFileBrowser", // <---- this makes filebrowser work!
mode: "exact",
elements: "id_content",
theme: "advanced",
skin_variant : "silver",
height: "250",
width: "800",
relative_urls: false,
language: "en",
directionality: "ltr",
spellchecker_languages : "Arabic=ar,Azerbaijani=az,Bulgarian=bg,Bengali=bn,Bosnian=bs,Catalan=ca,Czech=cs,Welsh=cy,Danish=da,German=de,Greek=el,+English / British English=en,Esperanto=eo,Spanish / Argentinian Spanish / Mexican Spanish / Nicaraguan Spanish=es,Estonian=et,Basque=eu,Persian=fa,Finnish=fi,French=fr,Frisian=fy,Irish=ga,Galician=gl,Hebrew=he,Hindi=hi,Croatian=hr,Hungarian=hu,Indonesian=id,Icelandic=is,Italian=it,Japanese=ja,Georgian=ka,Kazakh=kk,Khmer=km,Kannada=kn,Korean=ko,Lithuanian=lt,Latvian=lv,Macedonian=mk,Malayalam=ml,Mongolian=mn,Norwegian Bokmal=nb,Nepali=ne,Dutch=nl,Norwegian Nynorsk=nn,Punjabi=pa,Polish=pl,Portuguese / Brazilian Portuguese=pt,Romanian=ro,Russian=ru,Slovak=sk,Slovenian=sl,Albanian=sq,Serbian / Serbian Latin=sr,Swedish=sv,Swahili=sw,Tamil=ta,Telugu=te,Thai=th,Turkish=tr,Tatar=tt,Ukrainian=uk,Urdu=ur,Vietnamese=vi,Simplified Chinese / Traditional Chinese=zh",
spellchecker_rpc_url : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
plugins: "contextmenu,directionality,fullscreen,paste,preview,searchreplace,spellchecker,visualchars,wordcount",
paste_auto_cleanup_on_paste : true,
theme_advanced_buttons1 : "formatselect,fontsizeselect,|,undo,redo,|,cut,copy,paste,pastetext,pasteword,|,search,replace,|,visualchars,visualaid,cleanup,code,preview,fullscreen",
theme_advanced_buttons2 : "bold,italic,underline,strikethrough,|,forecolor,backcolor,removeformat,|,justifyleft,justifycenter,justifyright,justifyfull,|,sub,sup,|,bullist,numlist,|,outdent,indent,|,link,unlink,anchor,image,blockquote,hr,charmap,",
theme_advanced_buttons3 : ""
});