0
votes

I have a Django-powered site that's like a mini CMS. I want to let users with no HTML knowledge edit the contents of the page. The problem is that most of the pages have some more or less complex HTML bits in them (for example a Bootstrap accordion), which needs to be intact for the page to not break.

I tried setting up an WYSIWYG editor, but that turned out to be a disaster, because it heavily alters my HTML (removes attributes, adds p tags all over etc).

Is there a viable option to let people change the text of the page, but not the HTML structure?

For reference, my Page model looks like:

class Page(models.Model):
    title = models.CharField(max_length=150)
    content = models.TextField()
1
Have you looked at django-cms.org/en ?Wolph
Yes, I've done my research before starting the project, but none of the CMS' out there are going to do what I want. Plus, I'm a control freak and like to have full control over my app.Eduard Luca
Well, you can just have a form or something to update the content and show it with Django after passing it through the linebreaks filter: docs.djangoproject.com/en/1.7/ref/templates/builtins/…Wolph

1 Answers

2
votes

Have you tried django-content-edit (https://pypi.org/project/django-content-edit/) by David Burke.

Basically you then create HTML part of your pages and add CMS_CONTENT -tags to different places. Editing content is done using WYSIWYG -control in Django admin, where available features (links, images, styles, ...) can be limited using configurations. That gives you pretty good control of everything.

It has it's own problems, like it easily messes up HTML stuff you have added in RAW view, because it automatically opens content in WYSIWYG view, which seems to remove HTML tags it does not understand/support. It also doesn't work YET with Django 2.0, because on_delete is now mandatory for ForeignKey and OneToOneField model fields.

I know this is very old question, but I answered anyway.