Christopher
Christopher

Reputation: 179

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

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?

Upvotes: 5

Views: 8007

Answers (4)

pyjavo
pyjavo

Reputation: 1613

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 : ""
});

Upvotes: 0

JChen___
JChen___

Reputation: 3701

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/')

Upvotes: 0

Rakesh
Rakesh

Reputation: 82765

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

Upvotes: 12

JamesO
JamesO

Reputation: 25936

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

Upvotes: 3

Related Questions