diff --git a/djangocms_column/cms_plugins.py b/djangocms_column/cms_plugins.py index 627ca8d..909a312 100644 --- a/djangocms_column/cms_plugins.py +++ b/djangocms_column/cms_plugins.py @@ -1,6 +1,6 @@ from django.utils.translation import gettext_lazy as _ -from cms.models import CMSPlugin +from cms import api from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool @@ -22,13 +22,12 @@ def save_model(self, request, obj, form, change): request, obj, form, change ) for _x in range(int(form.cleaned_data['create'])): - col = Column( - parent=obj, + col = api.add_plugin( placeholder=obj.placeholder, + plugin_type=ColumnPlugin.__name__, language=obj.language, + target=obj, width=form.cleaned_data['create_width'], - position=CMSPlugin.objects.filter(parent=obj).count(), - plugin_type=ColumnPlugin.__name__ ) col.save() return response