Skip to content

Instantly share code, notes, and snippets.

@driesdesmet
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save driesdesmet/8d1eed9f7a64167a6bbd to your computer and use it in GitHub Desktop.

Select an option

Save driesdesmet/8d1eed9f7a64167a6bbd to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from cms.models.pluginmodel import CMSPlugin
def addconfig(apps, schema_editor):
# Existing Quote Plugins don't have a configuration model, they use the default CMSPlugin, but now they should be
# using RandomQuotePlugin which stores the amount of quotes to show. We add a default of 1, to make it backwards
# compatible.
RandomQuotePlugin = apps.get_model("cmsplugin_randomquote", "RandomQuotePlugin")
for plugin in CMSPlugin.objects.filter(plugin_type="QuotePlugin"):
randomquoteplugin = RandomQuotePlugin(cmsplugin_ptr=plugin)
randomquoteplugin.save()
class Migration(migrations.Migration):
dependencies = [
('cms', '0011_auto_20150419_1006'),
('cmsplugin_randomquote', '0002_randomquoteplugin'),
]
operations = [
migrations.RunPython(addconfig),
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment