Skip to content

Instantly share code, notes, and snippets.

@aaugustin
Created July 23, 2012 16:25
Show Gist options
  • Save aaugustin/3164559 to your computer and use it in GitHub Desktop.
Save aaugustin/3164559 to your computer and use it in GitHub Desktop.
Migrate from CMS_REDIRECTS=True to django.contrib.redirects
from cms.models import Title
from django.contrib.redirects.models import Redirect
titles_with_redirect = Title.objects.exclude(redirect__isnull=True).exclude(redirect=u'')
for title in titles_with_redirect.select_related('page__site'):
Redirect.objects.create(
site=title.page.site,
old_path=u'/%s/' % title.path,
new_path=title.redirect,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment