jrief / djangocms-cascade

Build Single Page Applications using the Django-CMS plugin system
MIT License
166 stars 85 forks source link

0.4.0 - BootstrapContainerPluginModel has not been registered with django-reversion #50

Closed creimers closed 9 years ago

creimers commented 9 years ago

I don't quite know what to make of this...

I have installed

django-cms==3.0.7
Django==1.6.8
djangocms-cascade==0.4.0

In my settings.py:

CMSPLUGIN_CASCADE_PLUGINS = ('cmsplugin_cascade.bootstrap3',)

Upon publishing a page containing cascade plugins, I get this error message:

<class 'cmsplugin_cascade.models.BootstrapContainerPluginModel'> has not been registered with django-reversion

What am I missing?

jrief commented 9 years ago

Please try again without django-reversion.

creimers commented 9 years ago

You mean pip uninstall django-reversion?

jrief commented 9 years ago

no, you just have to remove it from INSTALLED_APPS. Note that cmsplugin_cascade.models.BootstrapContainerPluginModel is a proxy model, generated on the fly. Therefore please refer to the docs in django-reversion about how to handle these kinds of models.

creimers commented 9 years ago

Commenting out django reversion does the trick. But then, there's no reversion of course.

There is a long thread on github about reversion and proxy models concluding that proxy model support has been merged into master: https://github.com/etianen/django-reversion/issues/134

I still have to get to the bottom of this...

aaronsgithub commented 9 years ago

Hi @jrief, great work with djangocms-cascade - I'm a big fan of this project.

I'm just wondering if there are any plans to support django-reversion in the near future?

Thanks

jrief commented 9 years ago

Any volunteer who wants to do this work?

aer0s commented 9 years ago

Well this appears to resolve the issue by registering the proxy model just after creation:

diff --git a/cmsplugin_cascade/plugin_base.py b/cmsplugin_cascade/plugin_base.py
index 45616ea..6400cee 100755
--- a/cmsplugin_cascade/plugin_base.py
+++ b/cmsplugin_cascade/plugin_base.py
@@ -12,6 +12,7 @@ from .sharable.forms import SharableGlossaryMixin
 from .extra_fields.mixins import ExtraFieldsMixin
 from .widgets import JSONMultiWidget
 from . import settings
+import reversion

 class CascadePluginBaseMetaclass(CMSPluginBaseMetaclass):
@@ -37,6 +38,7 @@ class CascadePluginBaseMetaclass(CMSPluginBaseMetaclass):
             base_model = CascadeElement
         model_mixins = attrs.pop('model_mixins', ())
         attrs['model'] = CascadePluginBaseMetaclass.create_model(name, model_mixins, base_model)
+        reversion.register(attrs['model'])
         return super(CascadePluginBaseMetaclass, cls).__new__(cls, name, bases, attrs)
jrief commented 9 years ago

Is this just that simple - you only have to register the model? Oh my god, if I would have known this earlier, I would have implemented it myself. Many thanks for this PR! Do you think it will work with Django-1.6 as well?