{ "info": { "author": "Paul McLanahan", "author_email": "pmac@mozilla.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# django-redirect-urls\n\n[![Build Status](https://travis-ci.org/pmac/django-redirect-urls.svg?branch=master)](https://travis-ci.org/pmac/django-redirect-urls)\n\nManage URL redirects and rewrites in Django like you do other URLs: in code.\n\nThis was extracted from [bedrock](https://github.com/mozilla/bedrock/) (the code behind www.mozilla.org).\nWe had a lot of redirects and rewrites we wanted to move out of Apache configs and into versioned code.\nThis library is the result of all of that. Because it started life on a Mozilla site it does have some\nfeatures for how we make sites (e.g. locale prefixing in URLs and the `is_firefox` helper). Now that it\nis a separate thing however I'm very open to adding features and helpers for a more general audience.\n\n## Install\n\n```bash\n$ pip install django-redirect-urls\n```\n\n## Examples\n\nWith this library you can do things like:\n\n```python\n# urls.py\nfrom redirect_urls import redirect\n\nurlpatterns = [\n redirect(r'projects/$', 'mozorg.product'),\n redirect(r'^projects/seamonkey$', 'mozorg.product', locale_prefix=False),\n redirect(r'apps/$', 'https://marketplace.firefox.com'),\n redirect(r'firefox/$', 'firefox.new', name='firefox'),\n redirect(r'the/dude$', 'abides', query={'aggression': 'not_stand'}),\n]\n```\n\nThere are a lot of options to the `redirect` helper. Here is the basic list:\n\n* **pattern**: the regex against which to match the requested URL.\n* **to**: either a url name that `reverse` will find, a url that will simply be returned,\n or a function that will be given the request and url captures, and return the\n destination.\n* **permanent**: boolean whether to send a 301 or 302 response.\n* **locale_prefix**: automatically prepend `pattern` with a regex for an optional locale\n in the url. This locale (or None) will show up in captured kwargs as 'locale'.\n* **anchor**: if set it will be appended to the destination url after a '#'.\n* **name**: if used in a `urls.py` the redirect URL will be available as the name\n for use in calls to `reverse()`. Does _NOT_ work if used in a `redirects.py` file.\n* **query**: a dict of query params to add to the destination url.\n* **vary**: if you used an HTTP header to decide where to send users you should include that\n header's name in the `vary` arg.\n* **cache_timeout**: number of hours to cache this redirect. just sets the proper `cache-control`\n and `expires` headers.\n* **decorators**: a callable (or list of callables) that will wrap the view used to redirect\n the user. equivalent to adding a decorator to any other view.\n* **re_flags**: a string of any of the characters: \"iLmsux\". Will modify the `pattern` regex\n based on the documented meaning of the flags (see python re module docs).\n* **to_args**: a tuple or list of args to pass to reverse if `to` is a url name.\n* **to_kwargs**: a dict of keyword args to pass to reverse if `to` is a url name.\n* **prepend_locale**: if true the redirect URL will be prepended with the locale from the\n requested URL.\n* **merge_query**: merge the requested query params from the `query` arg with any query params\n from the request.\n\nOr you can install the `redirect_urls.middleware.RedirectsMiddleware` middleware and create \n`redirects.py` files in your Django apps. This will allow you to define a lot of redirects\nin their own files (which will be auto-discovered) and guarantee that they'll be tested before \nthe rest of your URLs.\n\n```python\n# redirects.py\nfrom redirect_urls import redirect\n\nredirectpatterns = [\n redirect(r'projects/$', 'mozorg.product'),\n redirect(r'^projects/seamonkey$', 'mozorg.product', locale_prefix=False),\n redirect(r'apps/$', 'https://marketplace.firefox.com'),\n redirect(r'firefox/$', 'firefox.new', name='firefox'),\n redirect(r'the/dude$', 'abides', query={'aggression': 'not_stand'}),\n]\n```\n\n## Run The Tests\n\n```bash\n$ pip install tox\n$ tox\n```\n\n## History\n\n### 1.0 - 2018-06-01\n\nAdd support for Django 1.11 and 2.0, and drop support for earlier versions.\n\n### 0.2 - 2017-05-09\n\nInitial release.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/pmac/django-redirect-urls/", "keywords": "django redirects", "license": "Apache-2.0", "maintainer": "", "maintainer_email": "", "name": "django-redirect-urls", "package_url": "https://pypi.org/project/django-redirect-urls/", "platform": "", "project_url": "https://pypi.org/project/django-redirect-urls/", "project_urls": { "Homepage": "https://github.com/pmac/django-redirect-urls/" }, "release_url": "https://pypi.org/project/django-redirect-urls/1.0/", "requires_dist": [ "Django (>=1.11)" ], "requires_python": "", "summary": "URL redirecting and rewriting in code.", "version": "1.0" }, "last_serial": 3922203, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "3711b4215bc703df3ca75480c8949223", "sha256": "267f20cc44de96fc574b5b02e9efcd80f4aab4146539dea1f4228f62f34bb4f5" }, "downloads": -1, "filename": "django_redirect_urls-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3711b4215bc703df3ca75480c8949223", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14906, "upload_time": "2017-04-21T19:28:07", "url": "https://files.pythonhosted.org/packages/09/4a/ff599980478e388ca8fcaaedf96f51bd09c673fe391d76f91051e9e98f15/django_redirect_urls-0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6e400c8e91706390602fbe14f48a16b9", "sha256": "cd8499424e4920dc929bf1d64c5563349471353143af8e631033336570c42445" }, "downloads": -1, "filename": "django-redirect-urls-0.1.tar.gz", "has_sig": false, "md5_digest": "6e400c8e91706390602fbe14f48a16b9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10236, "upload_time": "2017-04-21T19:28:09", "url": "https://files.pythonhosted.org/packages/7f/c0/6aa7cd03522d725a2c8e2c690d3b17cc6871b4531a187b9878573d400ec2/django-redirect-urls-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "6c96df62f994374205beb8ca23039a8b", "sha256": "bb8806327e0a5c9c98393836e6339d374d56ec0a95b945b67ec9650d4ae27638" }, "downloads": -1, "filename": "django_redirect_urls-0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6c96df62f994374205beb8ca23039a8b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14820, "upload_time": "2017-05-09T18:39:07", "url": "https://files.pythonhosted.org/packages/9b/f5/7a162dc807b3c1564f71a21d4f07cd5ee86d8bd2f2ac78e2c145d9a909d7/django_redirect_urls-0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6c2303601f8e4a08292d4887760fcad7", "sha256": "3c765f0791ade7c5814089425dd095af9ff18d56026f233774744d27103441db" }, "downloads": -1, "filename": "django-redirect-urls-0.2.tar.gz", "has_sig": false, "md5_digest": "6c2303601f8e4a08292d4887760fcad7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11405, "upload_time": "2017-05-09T18:39:09", "url": "https://files.pythonhosted.org/packages/f4/2e/ea3fac18215312846abeec9deee9d47856bdc89103a2c03c3a6622d0c8c9/django-redirect-urls-0.2.tar.gz" } ], "1.0": [ { "comment_text": "", "digests": { "md5": "c4fa2eb537e02ca03edb45a9f21455bb", "sha256": "c4cd7818b06ccf0a5307656a33f3ecea47ee22f0cceb374ea559eb2d1402d5d8" }, "downloads": -1, "filename": "django_redirect_urls-1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c4fa2eb537e02ca03edb45a9f21455bb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12412, "upload_time": "2018-06-01T20:50:02", "url": "https://files.pythonhosted.org/packages/d2/b5/4bb94608dd172bdc164837b7db0ab3942c4b2780894c3ea254ad84541028/django_redirect_urls-1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4291f2772afcaba0651b978bf182e604", "sha256": "e5b1dec666758c7d2621ce337458a09e4b3feeb06cb9ec5d43b17d66b87ea97d" }, "downloads": -1, "filename": "django-redirect-urls-1.0.tar.gz", "has_sig": false, "md5_digest": "4291f2772afcaba0651b978bf182e604", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11701, "upload_time": "2018-06-01T20:50:03", "url": "https://files.pythonhosted.org/packages/45/8d/b74b732f846eff25a15c4986097ddec499e0ce4a3c34df2f686942b56986/django-redirect-urls-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c4fa2eb537e02ca03edb45a9f21455bb", "sha256": "c4cd7818b06ccf0a5307656a33f3ecea47ee22f0cceb374ea559eb2d1402d5d8" }, "downloads": -1, "filename": "django_redirect_urls-1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c4fa2eb537e02ca03edb45a9f21455bb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12412, "upload_time": "2018-06-01T20:50:02", "url": "https://files.pythonhosted.org/packages/d2/b5/4bb94608dd172bdc164837b7db0ab3942c4b2780894c3ea254ad84541028/django_redirect_urls-1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4291f2772afcaba0651b978bf182e604", "sha256": "e5b1dec666758c7d2621ce337458a09e4b3feeb06cb9ec5d43b17d66b87ea97d" }, "downloads": -1, "filename": "django-redirect-urls-1.0.tar.gz", "has_sig": false, "md5_digest": "4291f2772afcaba0651b978bf182e604", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11701, "upload_time": "2018-06-01T20:50:03", "url": "https://files.pythonhosted.org/packages/45/8d/b74b732f846eff25a15c4986097ddec499e0ce4a3c34df2f686942b56986/django-redirect-urls-1.0.tar.gz" } ] }