[Django]-Django CMS: Update from aldryn-blog to aldryn-newsblog

4đź‘Ť

here’s my answers to some of your questions:

How can aldryn-newsblog leads be made HTML compatible?

Yes, Aldryn newsblog uses djangocms-text-ckeditor’s HTMLField

How can aldryn-blog entries be migrated to aldryn-newsblog?

Very carefully 🙂 Kidding…

First of, the only way to do this migration is to stay on 1.6 during the whole process.
Meaning, don’t upgrade to Django >= 1.7 until this migration is fully done.

That said, in order to provide you with as much info as possible,
please post exact versions for the following packages (or pip freeze):

  • Django
  • django CMS
  • django taggit
  • Aldryn Blog
  • Aldryn News & Blog (is it already installed?)
  • Aldryn Categories (is it already installed?)
  • django-hvad
  • djangocms-text-ckeditor

Also, here’s some questions:

Are the Aldryn blog templates overridden in your project?

Are there custom extensions to Aldryn blog on your project?

Are the blog articles currently searchable? (haystack)

EDIT v1

The way I do these kinds of migrations is to write multiple django management commands, usually one “main” command that will call the others.

By doing this I can iterate faster locally and when ready (after lots of testing) run the command directly on prod (after upgrading necessary dependencies).

I highly recommend using stellar for quick database snapshots during local development of the migration. Allows you to snapshot and restore db instantly and is quite easy to setup.

Here’s a sample of such main command:

from django.core.management import call_command, CommandError
from django.core.management.base import NoArgsCommand
from django.db import connection

from south.db import db

from cms.models import Page


class Command(NoArgsCommand):
    can_import_settings = True

    def handle_noargs(self, **options):
        self.stdout.write("Running migrations.\n")

        # Migrate newsblog up to 0013
        call_command('migrate', 'aldryn_newsblog', '0013')

        # Now fake migration 0014 because we don't want the default
        # app config since we'll create it in a later step
        call_command('migrate', 'aldryn_newsblog', '0014', fake=True)
        # Now migrate all the way to 0027 because we need to fake 0028
        call_command('migrate', 'aldryn_newsblog', '0027')
        # This migration has unfortunate side effects when Aldryn blog
        # is installed in the system.
        # It's ok to fake it because is just a data migration
        call_command('migrate', 'aldryn_newsblog', '0028', fake=True)
        # Move to 0035 because we need to fake 0036
        call_command('migrate', 'aldryn_newsblog', '0035')
        # Because we're not using default apphook config, fake 0036
        call_command('migrate', 'aldryn_newsblog', '0036', fake=True)

        # Proceed with all migrations
        call_command('migrate')

        self.stdout.write('Setting up blog page.\n')
        call_command('setup_blog_page')

        self.stdout.write('Migrating Aldryn Blog to Aldryn News & Blog.\n')
        call_command('migrate_blog_to_newsblog')

Now, you need the setup_blog_page and migrate_blog_to_newsblog commands.
Before providing them I have another question:

Are you using any of the plugins provided by Aldryn blog? Like Authors or Tags?

👤Paulo

Leave a comment