Skip to content

Commit

Permalink
Update cms_plugins.py - now using cms.api to add columns
Browse files Browse the repository at this point in the history
Using cms.api to make the plugin compatible with django-cms v4 as well. This patch also works for django-cms v3
  • Loading branch information
aacimov authored May 10, 2024
1 parent 839c81f commit a5f59db
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions djangocms_column/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from cms.models import CMSPlugin

Check failure on line 3 in djangocms_column/cms_plugins.py

View workflow job for this annotation

GitHub Actions / flake8

'cms.models.CMSPlugin' imported but unused
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

Expand All @@ -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
Expand Down

0 comments on commit a5f59db

Please sign in to comment.