Skip to main content

django painless redirects

CI Version Licence PyPI Downloads

like django.contrib.redirects, on steroids. maybe.

Features

  • simple redirects table, with that bit more flexibility / convenience
    • django sites framework support
    • wildcard matching
    • explicit limit to site/domain
    • explicit redirect to site
    • decide if you want to keep GET vars
    • move complete trees (/old/productXY to /new/productXY, with one redirect, for all products)
  • force site domain middleware, that redirects to current site's domain, if not already there

Yet to be done:

  • decide if to include GET vars when matching a redirect
  • contrib packages with "magic" redirects for django-cms, django-filer -> SEO getting easy.

Installation

To get the latest stable release from PyPi

pip install django-painless-redirects

Add painless_redirects to your INSTALLED_APPS

INSTALLED_APPS = (
    ...,
    'painless_redirects',
)

Add the following middlware to MIDDLEWARE, to make basic manual redirects work.

painless_redirects.middleware.ManualRedirectMiddleware

As a rule of thumb, you'll add the middleware rather at the end of the list. If you add it more at the beginning, other redirecting middlewares will get priority - for example, you'll not be able to redirect any path without having a language slug first, when LocaleMiddleware is before our middleware.

If you want to always redirect to the domain name entered in your current site (django.contrib.sites must be installed), also add this middleware (position is not that important):

painless_redirects.middleware.ForceSiteDomainRedirectMiddleware

Compatibility

  • django 1.11: should use django-painless-redirects<0.3.6 (not supported anyway since april 2020)

Usage

Add and manage your redirects in the django admin panel, under "painless redirects" > "redirects". Check hits, check auto created redirects, enable them if needed.

Settings

  • PAINLESS_REDIRECTS_INDEXED_CHARFIELD_MAX_LENGTH (default: 800) - needed for mysql (set to ~255). forces you to add 'painless_redirects' to settings.MIGRATION_MODULES
  • PAINLESS_REDIRECTS_AUTO_CREATE (default: True) - auto create redirects when a 404 is encountered
  • PAINLESS_REDIRECTS_AUTO_CREATE_ENABLED (default: False) - should auto created redirects be enabled instantly? beware, enabling this feature might ruin your SEO, but could also be a real timesaver...
  • PAINLESS_REDIRECTS_AUTO_CREATE_TO_PATH (default: '/') - where to redirect to, when a 404 is auto created
  • PAINLESS_REDIRECTS_AUTO_CREATE_SITE (default: True) - limit auto created redirects to the current site (from the django sites framework)

Development

  • there is test app, available with ./manage.py runserver.
  • quick tests, within your current env: ./manage.py test
  • to run tests with django 1.11 / 2.0 / 2.1 / ... : tox

Contributions

If you want to contribute to this project, please perform the following steps

.. code-block:: bash

# Fork this repository
# Clone your fork
mkvirtualenv django-painless-redirects
pip install -r test_requirements.txt
git checkout -b feature_branch
# Implement your feature and tests
git add . && git commit
git push -u origin feature_branch
# Send us a pull request for your feature branch

Release files for django-painless-redirects 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-painless-redirects 0.7.1
File Size Uploaded
django-painless-redirects-0.7.1.tar.gz 23.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-painless-redirects 0.7.1
File Interpreter ABI Platform
django_painless_redirects-0.7.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 62.7 kB

Release files / django-painless-redirects-0.7.1.tar.gz

Download URL django-painless-redirects-0.7.1.tar.gz
Size 23.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1d08f665014d2ac8a4a897ae67f367b46914ac075215cd73ea52d109712227a1
BLAKE2b-256 checksum
How to use checksums
82aec7de89eff480fb906d7dd2b9fed58ec13676efffde1ba19251e98ca11eea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release files / django_painless_redirects-0.7.1-py2.py3-none-any.whl

Download URL django_painless_redirects-0.7.1-py2.py3-none-any.whl
Size 39.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
499715f32fee532a27610ecf068d69433abc607490500674ddb24f3f1b5c49df
BLAKE2b-256 checksum
How to use checksums
c3d9b73c77d048c0f7809247bb4a69481064fd705330ef4a091d2145d3828c2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.7.1 This release

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.1

2 release files

0.2

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page