在应用中使用 class 媒体
use class Media in apps
我的 django-cms
中有一些扩展页面和应用程序。我尝试像这样在我的应用程序中加载一些 JS 文件,在我的 admin.py
class CustomCodeAdmin(admin.ModelAdmin):
class Media:
js = ('js/connect.js', 'js/testing.js')
admin.site.register(CustomCode, CustomCodeAdmin)
但是我在我的扩展页面中有相同的配置并且它工作得很好。
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)
知道为什么它适用于一个而不适用于其他吗?
要在您的应用中包含 TinyMCE,download 库,并在项目的静态文件夹中包含 tinymce 文件夹。
之后,在 static/js 中创建一个 JS 文件来放置我的 tinyMCE 的配置 tinymce_config.js
在你的应用里面cms_plugin.py包括这个
class Media:
js = ('tinymce/tinymce.min.js', 'js/tinymce_config.js')
我的tinymce_config.js是这样的
// 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.
});
我用这个link 喜欢参考
我的 django-cms
中有一些扩展页面和应用程序。我尝试像这样在我的应用程序中加载一些 JS 文件,在我的 admin.py
class CustomCodeAdmin(admin.ModelAdmin):
class Media:
js = ('js/connect.js', 'js/testing.js')
admin.site.register(CustomCode, CustomCodeAdmin)
但是我在我的扩展页面中有相同的配置并且它工作得很好。
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)
知道为什么它适用于一个而不适用于其他吗?
要在您的应用中包含 TinyMCE,download 库,并在项目的静态文件夹中包含 tinymce 文件夹。
之后,在 static/js 中创建一个 JS 文件来放置我的 tinyMCE 的配置 tinymce_config.js
在你的应用里面cms_plugin.py包括这个
class Media:
js = ('tinymce/tinymce.min.js', 'js/tinymce_config.js')
我的tinymce_config.js是这样的
// 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.
});
我用这个link 喜欢参考