Django-tinymce and django-filebrowser, image upload Error finding Upload-Folder (MEDIA_ROOT + DIRECTORY)
Asked Answered
P

4

5

So I'm trying to get filebrowser working with tinymce in django. Evrything goes fine with tinymce, nice fancy text editor. When I try to open the file browser i get ImproperlyConfigured at /admin/filebrowser/browse/ Error finding Upload-Folder (MEDIA_ROOT + DIRECTORY). Maybe it does not exist?I don't get any errors in the console from that and so far as i can tell it should be looking for /media/filebrowser/ which definitely exist

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

my settings:

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",
}

my urls:

if settings.DEBUG:
        urlpatterns += patterns('',
        url(r'^media/(?P<path>.*)$', 'django.views.static.serve',  {'document_root': settings.MEDIA_ROOT,})
   )

urlpatterns += staticfiles_urlpatterns()

I'm running in debug mode, don't know if that's the problem, do have a weird issue where i can use the static url to load static files but they have to be in the media directory, though the filebrowser static files are in my static file location which fixed some installation problems, but putting those files in media location as well didn't change anything. Any ideas what is needed to do to get this to work?

Petrina answered 8/9, 2011 at 5:0 Comment(5)
DIRECTORY is set in filebrowser.settings by default to uploads/ does this folder exist inside your media root?Banded
Thought I did, but checking again it wasn't there, probably floating around somewhere. Any how double checked everything, the pop-up opens, displays images but clicking select doesn't do anything, I get FileBrowserDiologue is not defined, continuing to read the docs but any help is appreciated(I was really hoping to be able to browse local folders, but maybe not possible with filebrowser?)Petrina
how do I mark this as answered again? because that was indeed the answer I'd like to give you credit for it.Petrina
I switched to django-filebrowser-no-grappelli-for-django13 had to patch it but that posted in issues so no problem everything works beautifullyPetrina
ok pleased it worked, will move it to an answer.Banded
K
12

The Default FILEBROWSER_DIRECTORY is "uploads" so you should check if '/media/uploads' exists

Kathernkatheryn answered 25/5, 2012 at 4:10 Comment(0)
B
3

DIRECTORY is set in filebrowser.settings by default to uploads/ does this folder exist inside your media root?

This default can be changed in your settings.py with FILEBROWSER_DIRECTORY

Banded answered 9/9, 2011 at 7:53 Comment(0)
M
0

Yes, you should add a new directory names "uploads".

In it's official DOC, you can find the anwser.

https://django-filebrowser.readthedocs.org/en/3.5.2/settings.html#directory-relative-to-media-root

DIRECTORY = getattr(settings, "FILEBROWSER_DIRECTORY", 'uploads/')
Millymilman answered 1/9, 2013 at 13:51 Comment(0)
J
0

If anyone have the same issue, please read this post. It worked for me.

Excerpting the content for posterity:

If you want to use tinymce widget to edit zinnia blog posts you may also want to use filebrowser to insert / edit images using your media django media folder. It does not work out of the box.

  • install zinnia
  • install filebrowser
  • install django-tinymce

And create your own file admin/zinnia/entry/tinymce_textareas.js with content:

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 : ""
});
Jeopardize answered 28/4, 2014 at 3:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.