Open MaxDragonheart opened 3 years ago
It seems that there is a communication issue between django-tinymce and django-filebrowser when trying to insert a file using django-filebrowser in the django-tinymce editor.
One suggestion provided in the issue is to check if the URLs for both django-tinymce and django-filebrowser are correctly configured.
Another suggested workaround is to use django-ckeditor instead of django-tinymce, as django-ckeditor is known to work well with django-filebrowser.
It is also recommended to check the versions of django-tinymce and django-filebrowser, as there may be compatibility issues between older versions of the two packages. Updating to the latest versions of both packages may help resolve the issue.
It seems that there is a miscommunication between django-tinymce and django-filebrowser when using the filebrowser plugin in tinymce.
One possible cause of this issue is that the filebrowser plugin is not properly configured to work with django-filebrowser. To fix this, you can try the following steps:
Make sure that django-filebrowser is properly installed and configured in your Django project.
Check that the filebrowser plugin is included in your tinymce configuration:
TINYMCE_DEFAULT_CONFIG = {
'plugins': 'filebrowser',
# ...
}
# settings.py
FILEBROWSER_DIRECTORY = ''
FILEBROWSER_VERSIONS_BASEDIR = '_versions'
FILEBROWSER_VERSIONS = {
'admin_thumbnail': {'verbose_name': 'Admin Thumbnail', 'width': 60, 'height': 60, 'opts': 'crop'},
}
# admin.py
from django.contrib import admin
from django.urls import reverse
from django.utils.html import escape
from django.utils.safestring import mark_safe
from tinymce.widgets import TinyMCE
class TinyMCEAdmin(admin.ModelAdmin):
def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'content':
return db_field.formfield(widget=TinyMCE(attrs={'file_browser_callback': 'filebrowser'}))
return super().formfield_for_dbfield(db_field, **kwargs)
class Media:
js = ('tiny_mce/tiny_mce.js', 'tiny_mce/textareas.js', 'filebrowser/js/TinyMCEAdmin.js',)
css = {
'all': ('filebrowser/css/filebrowser.css',),
}
def get_urls(self):
urls = super().get_urls()
urls += [
path('tinymce/', include('tinymce.urls')),
path('admin/filebrowser/', filebrowser_site.urls),
]
return urls
admin.site.register(MyModel, TinyMCEAdmin)
I think this is not a bug but my misunderstaning about the setting up between this package and django-filebrowser.
I'm using:
In
settings.py
I've this:In
urls.py
I've this:I'm be able to use Tinymce as you can see on the image below
But I can't use django-filebrowser.
I've created an image field that use django-filebrowser and it is possible to add media without problems.
Probably I'm forgot something, but what?