Package: lc-django-ckeditor
Django CKEditorNOTICE: django-ckeditor 5 has backwards incompatible code moves against 4.5.1.File upload support has been moved to ckeditor_uploader.  The urls are in ckeditor_uploader.urls, while for the file uploading widget you have to use RichTextUploadingField instead of RichTextField.Django admin CKEditor integration.Provides aRichTextField,RichTextUploadingField,CKEditorWidgetandCKEditorUploadingWidgetutilizing CKEditor with image uploading and browsing support included.This version also includes:support to django-storages (works with S3)updated ckeditor to version 4.9included all ckeditor language and plugin files to made everyone happy! (only the plugins maintained by the ckeditor develops team)ContentsDjango CKEditorInstallationRequiredRequired for using widget with file uploadOptional - customizing CKEditor editorOptional for file uploadUsageFieldWidgetOutside of django adminManagement CommandsUsing S3If you want to use allowedContentPlugins:Restricting file uploadDemo / Test applicationRunning selenium testRunning code quality testsTroubleshootingExample ckeditor configurationAUTHORSCreated ByContributorsChangelog5.6.15.6.05.5.05.4.05.3.15.3.05.2.25.2.15.2.05.1.15.1.05.0.35.0.25.0.15.0.0 (4.5.3)4.5.14.5.04.4.84.4.74.4.64.4.54.4.44.4.04.2.84.2.74.2.5 / 4.2.64.2.44.2.34.2.24.2.14.0.23.6.2.13.6.20.0.90.0.80.0.70.0.60.0.50.0.40.0.30.0.20.0.1InstallationRequiredInstall or add django-ckeditor to your python path.pip install django-ckeditorAddckeditorto yourINSTALLED_APPSsetting.Run thecollectstaticmanagement command:$ ./manage.py collectstatic. This will copy static CKEditor required media resources into the directory given by theSTATIC_ROOTsetting. SeeDjango’s documentation on managing static filesfor more info.CKEditor needs to know where its assets are located because it loads them
lazily only when needed. The location is determined in theckeditor-init.jsscript. and defaults tostatic/ckeditor/ckeditor/. This does not work all
the time, for example when usingManifestStaticFilesStorage, any asset
packaging pipeline or whatnot. django-ckeditor is quite good at automatically
detecting the correct place even then, but sometimes you have to hardcodeCKEDITOR_BASEPATHsomewhere. This can be hardcoded in settings, i.e.:CKEDITOR_BASEPATH = "/my_static/ckeditor/ckeditor"It is possible to override
theadmin/change_form.htmltemplate with your own if you really need to do
this, i.e.:{% extends "admin/change_form.html" %}

{% block extrahead %}
<script>window.CKEDITOR_BASEPATH = '/my_static/ckeditor/ckeditor/';</script>
{{ block.super }}
{% endblock %}Of course you should adapt this snippet to your needs when using
CKEditor outside the admin app.Required for using widget with file uploadAddckeditor_uploaderto yourINSTALLED_APPSsetting.Add aCKEDITOR_UPLOAD_PATHsetting to the project’ssettings.pyfile. This setting specifies a relative path to your CKEditor media upload directory. CKEditor uses Django’s storage API. By default, Django uses the file system storage backend (it will use yourMEDIA_ROOTandMEDIA_URL) and if you don’t use a different backend you have to have write permissions for theCKEDITOR_UPLOAD_PATHpath withinMEDIA_ROOT, i.e.:CKEDITOR_UPLOAD_PATH = "uploads/"When using default file system storage, images will be uploaded to “uploads” folder in yourMEDIA_ROOTand urls will be created againstMEDIA_URL(/media/uploads/image.jpg).If you want be able for have control for filename generation, you have to add into settings yours custom filename generator:# utils.py

def get_filename(filename):
    return filename.upper()# settings.py

CKEDITOR_FILENAME_GENERATOR = 'utils.get_filename'CKEditor has been tested with django FileSystemStorage and S3BotoStorage.
There are issues using S3Storage from django-storages.For the default filesystem storage configuration,MEDIA_ROOTandMEDIA_URLmust be set correctly for the media files to work (like those uploaded by the ckeditor widget).Add CKEditor URL include to your project’surls.pyfile:url(r'^ckeditor/', include('ckeditor_uploader.urls')),Note that by adding those URLs you add views that can upload and browse through uploaded images. Since django-ckeditor 4.4.6, those views are decorated using@staff_member_required. If you want a different permission decorator (login_required,user_passes_testetc.) then add views defined inckeditor.urlsmanually to your urls.py.SetCKEDITOR_IMAGE_BACKENDto one of the supported backends to enable thumbnails in ckeditor gallery. By default no thumbnails are created and full size images are used as preview. Supported backends:pillow: Uses PillowOptional - customizing CKEditor editorAdd a CKEDITOR_CONFIGS setting to the project’ssettings.pyfile. This specifies sets of CKEditor settings that are passed to CKEditor (see CKEditor’sSetting Configurations), i.e.:CKEDITOR_CONFIGS = {
    'awesome_ckeditor': {
        'toolbar': 'Basic',
    },
}The name of the settings can be referenced when instantiating a RichTextField:content = RichTextField(config_name='awesome_ckeditor')The name of the settings can be referenced when instantiating a CKEditorWidget:widget = CKEditorWidget(config_name='awesome_ckeditor')By specifying a set nameddefaultyou’ll be applying its settings to all RichTextField and CKEditorWidget objects for whichconfig_namehas not been explicitly definedCKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'full',
        'height': 300,
        'width': 300,
    },
}It is possible to create a custom toolbarCKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'Custom',
        'toolbar_Custom': [
            ['Bold', 'Italic', 'Underline'],
            ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
            ['Link', 'Unlink'],
            ['RemoveFormat', 'Source']
        ]
    }
}If you want or need plugins which are not part of django-ckeditor’s
plugin set you may specify assets and plugins as follows:text = RichTextField(
    config_name='forum-post',

    # CKEDITOR.config.extraPlugins:
    extra_plugins=['someplugin'],

    # CKEDITOR.plugins.addExternal(...)
    external_plugin_resources=[(
        'someplugin',
        '/static/.../path-to-someplugin/',
        'plugin.js',
    )],
)Optional for file uploadAll uploaded files are slugified by default. To disable this feature, setCKEDITOR_UPLOAD_SLUGIFY_FILENAMEtoFalse.Set theCKEDITOR_RESTRICT_BY_USERsetting toTruein the project’ssettings.pyfile (defaultFalse). This restricts access to uploaded images to the uploading user (e.g. each user only sees and uploads their own images).  Upload paths are prefixed by the string returned byget_username.  IfCKEDITOR_RESTRICT_BY_USERis set to a string, the named property is used instead.  Superusers can still see all images.NOTE: This restriction is only enforced within the CKEditor media browser.Set theCKEDITOR_BROWSE_SHOW_DIRSsetting toTrueto show directories on the “Browse Server” page. This enables image grouping by directory they are stored in, sorted by date.Set theCKEDITOR_RESTRICT_BY_DATEsetting toTrueto bucked uploaded files by year/month/day.You can set a custom file storage for CKEditor uploader by defining it underCKEDITOR_STORAGE_BACKENDvariable in settings.UsageFieldThe quickest way to add rich text editing capabilities to your models is to use the includedRichTextFieldmodel field type. A CKEditor widget is rendered as the form field but in all other regards the field behaves as the standard DjangoTextField. For example:from django.db import models
from ckeditor.fields import RichTextField

class Post(models.Model):
    content = RichTextField()For file upload supportuseRichTextUploadingFieldfromckeditor_uploader.fields.WidgetAlernatively you can use the includedCKEditorWidgetas the widget for a formfield. For example:from django import forms
from django.contrib import admin
from ckeditor.widgets import CKEditorWidget

from post.models import Post

class PostAdminForm(forms.ModelForm):
    content = forms.CharField(widget=CKEditorWidget())
    class Meta:
        model = Post

class PostAdmin(admin.ModelAdmin):
    form = PostAdminForm

admin.site.register(Post, PostAdmin)For file upload supportuseCKEditorUploadingWidgetfromckeditor_uploader.widgets.Outside of django adminWhen you are rendering a form outside the admin panel, you’ll have to make sure all form media is present for the editor to work. One way to achieve this is like this:<form>
    {{ myform.media }}
    {{ myform.as_p }}
    <input type="submit"/>
</form>or you can load the media manually as it is done in the demo app:{% load static %}
<script type="text/javascript" src="{% static "ckeditor/ckeditor-init.js" %}"></script>
<script type="text/javascript" src="{% static "ckeditor/ckeditor/ckeditor.js" %}"></script>When you need to renderRichTextField’s HTML output in your templates safely, just use{{ content|safe }},Django’s safe filterManagement CommandsIncluded is a management command to create thumbnails for images already contained inCKEDITOR_UPLOAD_PATH. This is useful to create thumbnails when using django-ckeditor with existing images. Issue the command as follows:$ ./manage.py generateckeditorthumbnailsNOTE: If you’re using custom views remember to include ckeditor.js in your form’s media either through{{ form.media }}or through a<script>tag. Admin will do this for you automatically. SeeDjango’s Form Media docsfor more info.Using S3Seehttps://django-storages.readthedocs.org/en/latest/NOTE:django-ckeditorwill not work with S3 throughdjango-storageswithout this line insettings.py:AWS_QUERYSTRING_AUTH = FalseIf you want to use allowedContentTo get allowedContent to work, disablestylesheetparserplugin.
So include this in your settings.py.:CKEDITOR_CONFIGS = {
    "default": {
        "removePlugins": "stylesheetparser",
    }
}Plugins:django-ckeditor includes the following ckeditor plugins, but not all are enabled by default:a11yhelp, about, adobeair, ajax, autoembed, autogrow, autolink, bbcode, clipboard, codesnippet,
codesnippetgeshi, colordialog, devtools, dialog, div, divarea, docprops, embed, embedbase,
embedsemantic, filetools, find, flash, forms, iframe, iframedialog, image, image2, language,
lineutils, link, liststyle, magicline, mathjax, menubutton, notification, notificationaggregator,
pagebreak, pastefromword, placeholder, preview, scayt, sharedspace, showblocks, smiley,
sourcedialog, specialchar, stylesheetparser, table, tableresize, tabletools, templates, uicolor,
uploadimage, uploadwidget, widget, wsc, xmlThe image/file upload feature is done by theuploadimageplugin.Restricting file uploadTo restrict upload functionality to image files only, addCKEDITOR_ALLOW_NONIMAGE_FILES = Falsein your settings.py file. Currently non-image files are allowed by default.By default the upload and browse URLs use staff_member_required decorator - ckeditor_uploader/urls.py - if you want other decorators just insert two urls found in that urls.py and don’t include it.Demo / Test applicationIf you clone the repository you will be able to run theckeditor_demoapplication.pip install-rckeditor_demo_requirements.txtRunpython manage.py migrateCreate a superuser if you want to test the widget in the admin panelStart the development server.There is a forms.Form on the main page (/) and a model in admin that uses the widget for a model field.
Database is set to sqlite3 and STATIC/MEDIA_ROOT to folders in temporary directory.Running selenium testYou can run the test withpython manage.py test ckeditor_demo(for repo checkout only) or withtoxwhich is configured to run with Python 2.7 and 3.4.Running code quality testsCreate a new virtualenv, installtoxand runtox-epy27-linttoFlake8 (pep8 and other quality checks)tests ortox-epy27-isorttoisort (import order check)testsTroubleshootingIf your browser has problems displaying uploaded images in the image upload window you may need to change Django settings:X_FRAME_OPTIONS = 'SAMEORIGIN'More onhttps://docs.djangoproject.com/en/1.11/ref/clickjacking/#setting-x-frame-options-for-all-responsesExample ckeditor configurationCKEDITOR_CONFIGS = {
    'default': {
        'skin': 'moono',
        # 'skin': 'office2013',
        'toolbar_Basic': [
            ['Source', '-', 'Bold', 'Italic']
        ],
        'toolbar_YourCustomToolbarConfig': [
            {'name': 'document', 'items': ['Source', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates']},
            {'name': 'clipboard', 'items': ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']},
            {'name': 'editing', 'items': ['Find', 'Replace', '-', 'SelectAll']},
            {'name': 'forms',
             'items': ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton',
                       'HiddenField']},
            '/',
            {'name': 'basicstyles',
             'items': ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']},
            {'name': 'paragraph',
             'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-',
                       'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl',
                       'Language']},
            {'name': 'links', 'items': ['Link', 'Unlink', 'Anchor']},
            {'name': 'insert',
             'items': ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe']},
            '/',
            {'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize']},
            {'name': 'colors', 'items': ['TextColor', 'BGColor']},
            {'name': 'tools', 'items': ['Maximize', 'ShowBlocks']},
            {'name': 'about', 'items': ['About']},
            '/',  # put this to force next toolbar on new line
            {'name': 'yourcustomtools', 'items': [
                # put the name of your editor.ui.addButton here
                'Preview',
                'Maximize',

            ]},
        ],
        'toolbar': 'YourCustomToolbarConfig',  # put selected toolbar config here
        # 'toolbarGroups': [{ 'name': 'document', 'groups': [ 'mode', 'document', 'doctools' ] }],
        # 'height': 291,
        # 'width': '100%',
        # 'filebrowserWindowHeight': 725,
        # 'filebrowserWindowWidth': 940,
        # 'toolbarCanCollapse': True,
        # 'mathJaxLib': '//cdn.mathjax.org/mathjax/2.2-latest/MathJax.js?config=TeX-AMS_HTML',
        'tabSpaces': 4,
        'extraPlugins': ','.join([
            'uploadimage', # the upload image feature
            # your extra plugins here
            'div',
            'autolink',
            'autoembed',
            'embedsemantic',
            'autogrow',
            # 'devtools',
            'widget',
            'lineutils',
            'clipboard',
            'dialog',
            'dialogui',
            'elementspath'
        ]),
    }
}AUTHORSCreated ByshaunsephtonContributorsriklaunim3point2buchukichr15mhedleyroosjeffhlihanloop0mwcztomwyssnbubackAnd othershttps://github.com/django-ckeditor/django-ckeditor/graphs/contributorsChangelog5.6.1Fix bad pypi package5.6.0Django 2.1 compatibility, minimal supported Django version is 1.11 LTSOption to set custom django file backend for CKEditor uploader app.5.5.0CKEditor 4.9.2Documentation improvementsAllow non-string properties of user for CKEDITOR_RESTRICT_BY_USER5.4.0Django 2.0 compatibility5.3.1Actually include the code which setsCKEDITOR_BASEPATH.CKEditor 4.7.35.3.0CKEditor 4.7Fix storage problems by settingCKEDITOR_BASEPATH(hopefully for real
this time)Documentation updatesAdded aCKEDITOR_RESTRICT_BY_DATEsetting to add uploaded files into
folders containing the current date.Added aCKEDITOR_FILEICONSsetting that allows overriding the
icons used by Gallerific.Added aCKEDITOR_FILENAME_GENERATORsetting which allows
specifying a callable which mangles the filename of uploaded files.AddedTHUMBNAIL_SIZEandIMAGE_QUALITYsettings for the
Pillow image backend.Actually include static assets forckeditor_uploaderin the
pip-installable package.RemovedCKEDITOR_JQUERY_URLand the jQuery dependency. The
CKEditor activation now uses plain JavaScript. Dependencies areJSON.parseanddocument.querySelectorAllwhich are supported in practically all used browsers these days.Fixed a bug where the CKEditor language was not set individually for
each request.5.2.2Django 1.11 supportDrop South migrationsFix storage problems by setting CKEDITOR_BASEPATH5.2.1Fix CKEditor package static path5.2.0Django 1.10 updatesDevelopment dependencies bumpCKEditor 4.6.1Paste image supportFix for ManifestStaticFilesStorage5.1.1Re-add missing additional CkEditor plugins5.1.0Updated CkEditor to 4.5.10Django 1.10 compatibility changesDocumentation updates5.0.3Fix file/directory browsing and searchingEditor width style fixesAdded CKEDITOR_BROWSE_SHOW_DIRSAdded CKEDITOR_ALLOW_NONIMAGE_FILESPython 2.6 compatibility fix5.0.2Added template missing in the package5.0.1Update Readme with backward-incompatible changes5.0.0 (4.5.3)Moved file upload code to new Django application - ckeditor_uploader.RichTextFielddoesn’t use file upload which have been moved toRichTextUploadingField.File upload support have been moved to ckeditor_uploader. The urls are in ckeditor_uploader.urls while for file uploading widget you have to use RichTextUploadingField from ckeditor_uploader.fields instead of RichTextField from  from ckeditor.fields.Updated ckeditor to 4.5.3 (fromhttps://github.com/ckeditor/ckeditor-dev/tree/4.5.3)Added new plugins from ckeditor maintainers: adobeair, ajax, autoembed, autogrow, autolink, bbcode, codesnippet, codesnippetgeshi, devtools, divarea, docprops, embed, embedbase, embedsemantic, filetools, iframedialog, image2, language, lineutils, mathjax, menubutton, notification, notificationaggregator, placeholder, sharedspace, sourcedialog, stylesheetparser, tableresize, uicolor, uploadimage, uploadwidget, widget, xmlAddzip_safe=Falseon setup config, to force does not create “.egg” fileAdd python Wheel package configurationAdd setup.py functions to easy release “.egg” package and Wheel package, and tag version on git (python setup.py publishandpython setup.py tag)Improved Tox configuration to code coverage check, code quality check (flake8), imports order check (isort) and test with django master branchAdd code quality configurationsAdd EditorConfig configuration fileRefactored code to be in compliance with PEP84.5.1Fixed unbound variable in non-image file upload4.5.0Updated ckeditor to 4.5.1Reverted django.contrib.staticfiles.templatetags.staticfiles.static usage causing problems with some storagesAllow non-image files to be upload (the upload widget expects images so the user experience isn’t best at the moment)Few refactors and fixes to selenium tests4.4.8Python 3 compatibility fixesGet static files paths in a proper wayFix Django 1.7 deprecation warningMore examples in readme4.4.7Allow only POST requests on upload view.Exclude hidden files from image browserPrevent caching of image browser viewUse lazy JSON encoder to support i18n in CKEditor settings.Misc documentation updatesCheck for jQuery presence correctlyUpdate to CKEditor 4.4.64.4.6Make upload/browse views be staff_member_required by default (can be overridden)Fix ckeditor initialisation code breaking with other jQuery versions.Support grappelli inline form widgets.Remove odd left margin from widget template.Allow running selenium tests with chromium.4.4.5Post merge package name fix in Readme4.4.4Update CKEditor to 4.4.4 full package - for all plugins and static files you may needFixes for inline editorEditor initialisation uses jQuery. You need to specify CKEDITOR_JQUERY_URL for it to work. You can use:CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'4.4.0Update CKEditor to 4.4.1Django 1.7 compatibility fix4.2.8Update CKEditor to 4.3.34.2.7Fix slugifying to empty filename if only bad characters given in filename. Use random string as fallback.Don’t use IMG tags for non image files in ckeditor file browser.Remove non-existing image reference from CSS files that broke collectstatic.Misc fixes4.2.5 / 4.2.6Fix static files installation - switch from distutils to setuptools4.2.4Added new demo application with selenium integration testtox setup for Python 3.3 and 2.7 testingExtracted image processing to backends. PIL/Pillow is optional now. Other backends can be added.Fixed a bug with thumbnail generation4.2.3Python 3.3 compatibilityAll uploaded files are slugified by default (New settings CKEDITOR_SLUGIFY_FILENAME)Upload file when editing a link (<a href>) now works properly4.2.2Python 3.3 compatibility in widgets.py4.2.1Include CKEditor version 4.2.1.Support Django 1.64.0.2Include CKEditor version 4.0.2.3.6.2.1Remove unwanted static files from distribution.Use Pillow instead of PIL since it builds on all systems.3.6.2Include CKEditor version 3.6.2.Initial work on Django aligned theme.Fix schema slash removal issue on media url generation. ThanksmwczAdded compatibility for South. Thanks3point2Prevented settings from leaking between widget instances. Thanks3point2Fixed config_name conflict when verbose_name is used as first positional argument for a field. Thanks3point2Refactored views to allow use of file walking with local paths. Thanks3point2Added command to generate thumbnails. Thanks3point2Migrated from using media to static file management.0.0.9Added ability to configure CKeditor through a CKEDITOR_CONFIGS settings. Thanksjeffhfor the input.0.0.8Removed buggy url include check.0.0.7Egg package corrected to exclude testing admin.py and models.py.0.0.6Enforce correct configuration.Changed upload behavior to separate files into directories by upload date. Thanksloop0.Added ability to limit user access to uploaded content (see the CKEDITOR_RESTRICT_BY_USER setting). Thankschr15mfor the input.Added initial set of much needed tests.General cleanup, light refactor.0.0.5csrf_exempt backwards compatability. Thankschr15m.0.0.4Include resources, sorry about that.0.0.3More robust PIL import. Thanksbuchuki.Better CKEDITOR_MEDIA_PREFIX setting error.0.0.2Included README.rst in manifest.0.0.1Added CKEDITOR_UPLOAD_PREFIX setting. Thankschr15mfor the input.