2016-11-14 29 views
0

我在我的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) 

任何想法,爲什麼它在一個而不是在其他人?

回答

0

要將TinyMCE包含在您的應用程序中,請在該項目的靜態文件夾中包含tinymce文件夾。

之後,內部的靜電/ 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喜歡引用