Search code examples
htmldjangockeditorckeditor4.x

How to manually define place for blog post preview using Django and CKEditor?


I have a blog written in Python + Django.

Before I started use of WYSIWYG editor, to create a blog post preview I manually added custom html tag <post_cut/> and used python slice to show only a preview. It allowed to avoid issues with fixed length for preview or breaking html tags.

Now I added Django-CKEditor and it removes all html tags which "it doesn't understand".

I tried to do something with configuration (allowedContentRules, format_tags and etc.) but no success.

The questions is how to manage "post-cut" and how to do this using CKEditor.
P.S. it would be awesome also to have button for that.


Solution

  • Found the answer by myself.
    You need to use extraAllowedContent if you want to add some extra tags.

    Also found how to add custom button by creating a custom plugin.
    But still looking for good solution that will utilize django-ckeditor

    CKEDITOR_CONFIGS = {
        'default': {
            'extraAllowedContent': {
                'post_cut': True,
            },
            # ...
            # (other options)
        }
    }