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?

Christopher
  • 169
  • 2
  • 6
  • DIRECTORY is set in filebrowser.settings by default to uploads/ does this folder exist inside your media root? – JamesO Sep 08 '11 at 08:13
  • 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?) – Christopher Sep 08 '11 at 16:53
  • how do I mark this as answered again? because that was indeed the answer I'd like to give you credit for it. – Christopher Sep 08 '11 at 16:56
  • I switched to django-filebrowser-no-grappelli-for-django13 had to patch it but that posted in issues so no problem everything works beautifully – Christopher Sep 08 '11 at 17:41
  • ok pleased it worked, will move it to an answer. – JamesO Sep 09 '11 at 07:51

4 Answers4

12

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

Rakesh
  • 81,458
  • 17
  • 76
  • 113
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

JamesO
  • 25,178
  • 4
  • 40
  • 42
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/')
JChen___
  • 3,593
  • 2
  • 20
  • 12
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 : ""
});
Jordan Reiter
  • 20,467
  • 11
  • 95
  • 161
pyjavo
  • 1,598
  • 2
  • 23
  • 41