Created
September 11, 2013 10:23
-
-
Save vjousse/6521823 to your computer and use it in GitHub Desktop.
Simple django command to output django_redirect redirections to nginx format
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 django.core.management.base import BaseCommand, CommandError | |
from django.contrib.redirects.models import Redirect | |
class Command(BaseCommand): | |
help = 'Print nginx redirections' | |
def handle(self, *args, **options): | |
for redirect in Redirect.objects.all(): | |
self.stdout.write('rewrite ^%s$ %s permanent;' % (redirect.old_path, redirect.new_path)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment