divio/django-cms — Issue #1130: Saved content HTML stores <img ...> instead of {{ plugin_object }}
Author: spookylukey
Created: 2012-01-02 23:49:23+00:00
State: open

The way that the admin for text plugins used to work (probably back in django-cms 1.0 days, I can't trace it all the way), was like this:

1. the admin would display tags to represent embedded plugins.
2. when saved, these would be converted to things like {{ plugin_object 123 }}
3. when rendered, these would be converted to the rendered output of the plugin object.

I know this, because I designed it, and it is described here: https://groups.google.com/forum/#!msg/django-cms/Q4L5m408U6I/-BtSqAReSTIJ

Unfortunately, for some reason step 2 has been removed, and step 3 modified to cope, I think mistakenly: https://github.com/divio/django-cms/commit/8ef98325cb01864929f0aa8ed76e1dee8e42d080#L12L50

So now the database is storing obscuring tags to represent plugins, making it harder to understand and more fragile (e.g. if some other editor is used to edit the HTML, which doesn't preserve the 'id' attribute on the tags, or if you want to export your data).

Fixing this would be tricky - we would need a datamigration to fix all up the this stuff, which could take a while to run.

We would also need to change the way that the admin saves the HTML, so that plugin_admin_html_to_tags is actually used. I haven't looked into doing this yet, but should just be a matter of appropriate code in the ModelAdmin.save_model()

The alternative is to just live with it, and fix the code accordingly. Currently there is a whole bunch of confusing cruft in cms/plugins/text/utils.py and some in cms/plugins/text/models.py

(I'm happy to do either of these., BTW).