django - How to setup TINYMCE to point to static_files? -
i using django 1.5.1, , know since django 1.3 world of media , statis files have been separated reasons.
to surprise django-tinymce's documentation referring how tinymce_js_url pointing default media url.
tinymce_js_url (default: settings.media_url + 'js/tiny_mce/tiny_mce.js')
that doesn't make sense. in django 1.3+ have static_url self hosted js , css files. trying change confusing , doesn't work.
this how setup static files settings:
static_root = '/home/kave/project-env/site/static/' static_url = '/static/' staticfiles_dirs = ('/home/kave/project-env/site/static_files/',)
in static_files directory have extracted tinymce zipfile: e.g. path this:
/home/kave/project-env/site/static_files/tinymce/js/tinymce/tinymce.min.js
then have set settings this:
tinymce_js_url = static_url + 'tinymce/js/tinymce/tinymce.min.js' tinymce_js_root = static_root + 'tinymce/js/tinymce'
however when app runs, see plain textfield instead of tinymce.
what have overlooked please?
i have figured out, hope helps else.
you need point built-in tiny_mce automatically installed through pip. no need download anything.
<script type="text/javascript" src="{{ static_url }}tiny_mce/tiny_mce.js"></script>
for admin screen, make sure have this:
class tinymceadmin(admin.modeladmin): class media: js = ('/static/tiny_mce/tiny_mce.js', ) admin.site.register(mymodel, tinymceadmin)
and don't forget config in settings.py
tinymce_default_config = { # general options 'mode' : "textareas", 'theme' : "advanced", 'plugins' : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave", # theme options 'theme_advanced_buttons1' : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,fontselect,fontsizeselect,", #fullscreen,code", 'theme_advanced_buttons2' : "bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,|,forecolor,backcolor", #'theme_advanced_buttons3' : "tablecontrols,|,hr,sub,sup,|,charmap", 'theme_advanced_toolbar_location' : "top", 'theme_advanced_toolbar_align' : "left", 'theme_advanced_statusbar_location' : "bottom", 'theme_advanced_resizing' : 'true', #example content css (should site css) #content_css : "/css/style.css", 'template_external_list_url' : "lists/template_list.js", 'external_link_list_url' : "lists/link_list.js", 'external_image_list_url' : "lists/image_list.js", 'media_external_list_url' : "lists/media_list.js", # style formats 'style_formats' : [ {'title' : 'bold text', 'inline' : 'strong'}, {'title' : 'red text', 'inline' : 'span', 'styles' : {'color' : '#ff0000'}}, {'title' : 'help', 'inline' : 'strong', 'classes' : 'help'}, {'title' : 'table styles'}, {'title' : 'table row 1', 'selector' : 'tr', 'classes' : 'tablerow'} ], 'width': '700', 'height': '400' }
other make sure use htmlfield inside model model textfield. in forms.py, if not using modelform, need define new widget well.
Comments
Post a Comment