Skip to content

Personal memo on dubest way to integrate amazing contenttools into django

License

Notifications You must be signed in to change notification settings

marojenka/django-content-tools-light

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django contenttools.js integration

Simplified example integration of amazing contenttools into Django project. The aim was to adopt contenttools in a WYSIWYG-editor manner with minimal changes to existing projects. It's simplified so that data is send via synchronous POST request.

This is for personal use, for proper integration one should use approach made in django-contenttools-demo.

Core

contenttools is a lovely customisable editor that allows you to easily generate content with hmtl-markup. Such an instrument is a perfect replacement for bunch of rich text editors loaded in django-admin interface without styles and context of a page.

In this simplest example pages are generated via Page model with content TextField. Contenttools is used to populate this field via synchronous POST request.

Everything that is (hardly) worth looking at are:

base/static/editor.js
pages/views.py
pages/templates/pages/page_form.html

Hacks

Editing non-html fields

In order to use contenttools not only for saving HTML markup but for editing embeded distict fields that should not be evaluated as HTML data little hack is suggested. One might wrap model field with desired html tag, h1 or p or any div, by contenttools and then in backend strip this tag keeping data and markup separated.

Remove image tool

Image tool is removed using standard way of contenttools in editor.js by using hardcoded knolage of where Image tool is localted in DEFAULT_TOOLS, so something might go wrong if one uses different DEFAULT_TOOLS array.

See also

License

MIT license

About

Personal memo on dubest way to integrate amazing contenttools into django

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published