django_ckeditorfiles

CKEditor bundled as a Django staticfiles app
Download

django_ckeditorfiles Ranking & Summary

Advertisement

  • Rating:
  • License:
  • LGPL
  • Price:
  • FREE
  • Publisher Name:
  • Espen Angell Kristiansen
  • Publisher web site:
  • http://devilry.github.com

django_ckeditorfiles Tags


django_ckeditorfiles Description

django_ckeditorfiles is a CKEditor bundled as a Django app.Installpip install ckeditorfilesSetupAdd 'ckeditorfiles' and 'django.contrib.staticfiles' to INSTALLED_APPS.ckeditor.jsThe entire source code of CKEditor is in static/ckeditorfiles/. This means that you can include the sources in your templates using:{% load staticfiles %}< script type="text/javascript" src="{% static "ckeditorfiles/ckeditor.js" %}" >< /script >(you do not need to do this if you use the CKEditorWidget)ckeditorfiles.widgets.CKEditorWidgetCKEditorWidget is a subclass of django.forms.widgets.Textarea. It automatically includes ckeditor.js, and adds:< script type="text/javascript" > CKEDITOR.replace(id, config);< /script >after the textarea. id is the id of the textarea, and config is the config parameter to the constructor of the widget, encoded as JSON.Examplefrom django import formsfrom ckeditorfiles.widgets import CKEditorWidgetfrom models import Pageclass PageForm(forms.ModelForm): body = forms.CharField(widget=CKEditorWidget(config={'toolbar': 'Basic', 'height': '300px'})) class Meta: model = PageThe config parameter to CKEditorWidget is the config parameter for CKEDITOR.replace(...). See: http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Setting_Configurations.Subclass CKEditorWidgetYou can create your own CKEditor configurations as re-usable classes by subclassing CKEditorWidget and provide defaults in the default_config class attribute:from ckeditorfiles.widgets import CKEditorWidgetclass MyCKEditorWidget(CKEditorWidget): default_config = {'toolbar': 'Basic', 'height': '300px'}The default_config class attribute provides defaults that can be overridden with config parameter for __init__, so you could override the height-config of MyCKEditorWidget like this:widget = MyCKEditorWidget(config={'height': '100px'})Product's homepage


django_ckeditorfiles Related Software