Created
July 23, 2012 16:25
-
-
Save aaugustin/3164559 to your computer and use it in GitHub Desktop.
Migrate from CMS_REDIRECTS=True to django.contrib.redirects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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