fallback to empty form inheriting from EntangledModelFormMixin
@@ -191,12 +191,17 @@ class TransparentContainer(TransparentWrapper):
return _leaf_transparent_plugins
+class CascadeFormMixin(EntangledModelFormMixin):
+ class Meta:
+ entangled_fields = {'glossary': []}
+
+
class CascadePluginBase(metaclass=CascadePluginBaseMetaclass):
change_form_template = 'cascade/admin/change_form.html'
model_mixins = () # model mixins added to the final Django model
parent_classes = None
alien_child_classes = False
- form = EntangledModelFormMixin
+ form = CascadeFormMixin # safety fallback for plugins without any form
class Media:
css = {'all': ['cascade/css/admin/partialfields.css', 'cascade/css/admin/editplugin.css']}
@@ -314,10 +319,10 @@ class CascadePluginBase(metaclass=CascadePluginBaseMetaclass):
def get_form(self, request, obj=None, **kwargs):
form = kwargs.get('form', self.form)
assert issubclass(form, EntangledModelFormMixin), "Form must inherit from EntangledModelFormMixin"
- if issubclass(form, ModelForm):
- kwargs['form'] = form
- else:
- kwargs['form'] = type(form.__name__, (form, ModelForm), {})
+ bases = (CascadeFormMixin, form)
+ if not issubclass(form, ModelForm):
+ bases += (ModelForm,)
+ kwargs['form'] = type(form.__name__, bases, {})
return super().get_form(request, obj, **kwargs)
def get_parent_instance(self, request=None, obj=None):
