Skip to main content

A simple redirects utility that uses a json file for redirects definitions

Project description


Import this in and assign it to urlpatterns BEFORE custom urls. (redirects should be hit first) e.g:

from django_redirects_file import load_redirects

urlpatterns = load_redirects()
urlpatterns += patterns('',
    url(r'^(?P<template>.*)/?$', TemplateFinder.as_view()),

Format of redirects.json

The json format is simply key/value pairs, from source to destination:

    "getubuntu/download_static": "",
    "testing/quantal/alpha1":    ""

To convert old “double spaced” redirects.txt:

    i.split('  ')[0:2] #ignore the 3rd item, in-line comments
    for i in open('/path/to/redirects.txt').readlines()
    if len(i.split('  ')) >= 2 #ignore whole comment lines

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-redirects-file, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size django-redirects-file-0.1.1.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page