Skip to content

Instantly share code, notes, and snippets.

@zanderle
Created February 4, 2016 15:28
Show Gist options
  • Save zanderle/048af167a0fe85a86112 to your computer and use it in GitHub Desktop.
Save zanderle/048af167a0fe85a86112 to your computer and use it in GitHub Desktop.
Plan for script to migrate a page from DjangoCMS Cascade to Aldryn Bootstrap plugin
# Usecase: I have a DjangoCMS website with content and everything. It is using DjangoCMS Cascade plugin and I'd like
# to start using Aldryn Bootstrap plugin. I'd like to have a script that migrates all my content from one plugin to
# the other, since I don't want to do manually.
# Assuming aldryn_bootstrap is already installed
# The hard part is to deal with Grid elements, because it has multiple levels. Other stuff (like buttons) can just be replaced
for container_plugin in all_bootstrap_containers_plugins:
for row_plugin in container_plugin.get_children().filter(row_plugin=True).order_by(position):
# Create left sibling of container_plugin
container_plugin.add_sibling('left', instance=new_row_plugin)
# For each column in row_plugin, create a new column in newly created row
for column in row_plugin.get_children().order_by(position):
new_row_plugin.add_child(instance=new_column)
# Copy the existing content into the new column
for plugin in column.get_children():
plugin.move(target=new_column, 'last-child')
# Delete the container and all its descendants
container_plugin.delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment