3

I've been trying to get django-filebrowser working in django-tinymce (using MCE v4.0.x) for a while now, and still can't get the file browser callback to work. Here's what I've done so far:

  1. Installed TinyMCE via pip, added necessary settings including the following default config:

    TINYMCE_DEFAULT_CONFIG = { 'theme': 'modern', 'relative_urls': False, 'plugins': 'image', }

  2. Used TinyMCE as a widget in one of my forms, like so:

    content = forms.CharField(widget=TinyMCE(attrs={'cols': 100, 'rows': 30}))

  3. Installed filebrowser (pip install django-filebrowser), added it to INSTALLED_APPS. Also added the setting TINYMCE_FILEBROWSER=True to settings, along with the necessary filebrowser settings.

I now have the result that a file browser button appears in the 'add image' dialog in TinyMCE, but when I click it I get the following error in my browser's JS console:

Uncaught TypeError: string is not a function

I also get the following Javascript error about loading the filebrowser plugin:

Failed to load resource: the server responded with a status of 500 (INTERNAL SERVER ERROR) http://localhost:8080/tinymce/filebrowser/
benwad
  • 6,414
  • 10
  • 59
  • 93

2 Answers2

0

The only way I have managed to get filebrowser working with MCE v.4 is with a fork of Django-tinymce-filebrowser:

https://github.com/philroche/Django-tinymce-filebrowser

I don't think django-filebrowser supports TinyMCE v.4, as per this reference: https://github.com/sehmaschine/django-filebrowser/pull/219

Perhaps there are some forks of django-filebrowser that do.

laidibug
  • 1,179
  • 8
  • 5
  • I've just tried that, but I'm still getting the `string is not a function` message. Removing `TINYMCE_FILEBROWSER=True` removed the 500 error finding the /filebrowser/ directory but when I click the file browser button I still get that `not a function` error. – benwad Mar 31 '14 at 16:55
  • Make sure there are no quotes on: file_browser_callback: mce_filebrowser and that the mce_filebrowser script is getting loaded so that the function can be found. That will fix the current error you are getting. Also note that the urls.py file uses the wrong import on line 1 it should be from django.conf.urls import * – laidibug Mar 31 '14 at 22:18
  • 1
    I also am experiencing the "string is not a function" problem trying to get filebrowser working with tinymce4. @laidibug Not sure what you mean by "make sure there are no quotes on..." - those values do have to be quoted (removing them generates django startup errors). – shacker Nov 10 '14 at 21:39
0

The 'string not a function" error is because the "mce_filebrowser" is in quotes inside the init function. It is looking for a script. First make sure that is not in quotes (in the script init, not in seetings.py, where yes, it should be a string value). Then make sure you have linked to the script file in static files or wherever in your project you are storing .js scripts.

bamabacho
  • 191
  • 2
  • 16