From a5f59db0815dc7cf58a723e202c634ba9e856f51 Mon Sep 17 00:00:00 2001 From: Aleks Acimovic Date: Fri, 10 May 2024 08:14:01 +0200 Subject: [PATCH] Update cms_plugins.py - now using cms.api to add columns Using cms.api to make the plugin compatible with django-cms v4 as well. This patch also works for django-cms v3 --- djangocms_column/cms_plugins.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/djangocms_column/cms_plugins.py b/djangocms_column/cms_plugins.py index 627ca8d..d96d230 100644 --- a/djangocms_column/cms_plugins.py +++ b/djangocms_column/cms_plugins.py @@ -3,7 +3,7 @@ from cms.models import CMSPlugin from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool - +from cms import api from .forms import MultiColumnForm from .models import Column, MultiColumns @@ -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