I have some extension page and apps in my django-cms
. I try to load some JS file in my app like this, in my admin.py
class CustomCodeAdmin(admin.ModelAdmin):
class Media:
js = ('js/connect.js', 'js/testing.js')
admin.site.register(CustomCode, CustomCodeAdmin)
But the I have the same configuration in my extension page and it works perfectly.
from django.contrib import admin
from cms.extensions import PageExtensionAdmin
from .models import IconExtension
class IconExtensionAdmin(PageExtensionAdmin):
class Media:
js = ('js/connect.js', 'js/testing.js')
admin.site.register(IconExtension, IconExtensionAdmin)
Any idea why it works in one and not in the others?
To include TinyMCE in your app, download the library, and include tinymce folder inside static folder of your project.
After that, inside static/js create a JS file to put the configuration of your tinyMCE in my case tinymce_config.js
In your app inside cms_plugin.py include this
class Media:
js = ('tinymce/tinymce.min.js', 'js/tinymce_config.js')
my tinymce_config.js is like this
// TinyMCE 4 configuration
// Modify the following code to customize TinyMCE
tinymce.init({
selector: "textarea",
// Only required plugins are included. However, you can add more as per your needs.
// Spellchecker plugin is excluded as it produces an error in version 4.x
plugins: [
"advlist autolink link image lists charmap preview hr",
"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media",
"table contextmenu emoticons textcolor"
],
// Customize the toolbars below. You can also add new ones.
toolbar1: "bold italic underline | blockquote | bullist numlist| hr | formatselect fontselect fontsizeselect",
toolbar2: "undo redo | forecolor backcolor | link unlink | image media | alignleft aligncenter alignright alignjustify | outdent indent | searchreplace |code",
// toolbar3: " add buttons here ",
// Aditional options. Customize them as per your needs.
height: 350,
resize: "both",
image_advtab: true,
toolbar_items_size: "medium",
menubar: true,
// Example content CSS (should be your site CSS) for better typography
content_css : "/static/css/style.css"
// If your stylesheet is inside `static/css/` directory, just replace
// `style.css` with your stylesheet's name. You don't need to change the path.
});
I use this link like references