{ "info": { "author": "Kevin Wetzels", "author_email": "kevin@roam.be", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3" ], "description": "============\ndjango-uturn\n============\n\nProvides the HTTP redirect flexibility of Django's ``login`` view to the rest\nof your views.\n\nHere's what happens when you --as an anonymous user-- try to access a view\nrequiring you to log in:\n\n1. Django redirects you to ``/login?next=/page-you-wanted-to-see``\n2. You log on\n3. Django's ``login`` view notices the ``next`` parameter and redirects you to\n ``/page-you-wanted-to-see`` rather than ``/``.\n\nWith Uturn, you'll be able to use the same feature by simply changing some\ntemplate code and adding middleware or decorators to your views.\n\n----\n\nInstallation\n------------\ndjango-uturn is available on Pypi::\n\n pip install django-uturn\n\nUturn is currently tested against Django versions 1.4, 1.5 and 1.6 (including\nPython 3.2 and 3.3).\n\n.. image:: https://secure.travis-ci.org/roam/django-uturn.png?branch=master\n\n\n----\n\nTypical use cases\n-----------------\n\nFrom master to detail and back again\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nYou've got a list of... let's say *fish*. All kinds of fish. To enable users to\nfind fish by species, you've added a filter. Enter ``bass`` and your list is\ntrimmed to only contain the Australian Bass, Black Sea Bass, Giant Sea Bass,\nBumble Bass...\n\nWait a minute! *Bumble Bass* isn't a species you've ever heard of - it's\nprobably the European Bass. So you hit the edit link of the Bumble Bass,\nchange the name and save the form. Your view redirects you to the list. The\nunfiltered list. *Aaargh!*\n\nIf you'd just used the Uturn redirect tools, you would have been redirected to\nthe filtered list. Much better (in most cases).\n\n\nMultiple origins\n^^^^^^^^^^^^^^^^\n\nThis is basically a more general application of the previous use case. Suppose\nyou have a form to create a new ticket that you can reach from both the project\npage and the ticket list page. When the user adds a new ticket, you want to\nmake sure she's redirected to the project page when she came from the project\npage and the ticket list page when she reached the form from the ticket list\npage.\n\nEnter Uturn.\n\n\nHow to use Uturn\n----------------\n\nRedirecting in views\n^^^^^^^^^^^^^^^^^^^^\n\nA typical form processing view function probably looks a bit like this::\n\n from django.shortcuts import redirect, render\n from forms import TicketForm\n\n def add_ticket(request):\n if request.method == 'POST':\n form = TicketForm(request.POST)\n if form.is_valid():\n form.save()\n return redirect('ticket-list')\n else:\n form = TicketForm()\n context = {'form': form}\n return render(request, 'tickets/ticket_list.html', context)\n\nThis view always redirects to the ticket list page. Add Uturn redirects::\n\n from django.shortcuts import render\n from uturn.decorators import uturn\n from forms import TicketForm\n\n @uturn\n def add_ticket(request):\n if request.method == 'POST':\n form = TicketForm(request.POST)\n if form.is_valid():\n form.save()\n return redirect('ticket-list')\n else:\n form = TicketForm()\n context = {'form': form}\n return render(request, 'tickets/ticket_list.html', context)\n\nWe simply add the ``uturn`` decorator to the view which will check the request\nfor a valid ``next`` parameter and - if present - use that value as the\ntarget url for the redirect *instead* of the one you specified.\n\nIf you want to apply Uturn's redirect logic to *all* requests, add the\n``uturn.middleware.UturnMiddleware`` class to your middleware instead.\n\n\nPassing the *next* page along\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nHow do you add that ``next`` parameter to the URL in your project page?\nHere's what you'd normally use::\n\n Add ticket\n\nThis would render, depending on your url conf of course, a bit like this::\n\n Add ticket\n\nHere's what you'd use with Uturn::\n\n {% load uturn %}\n Add ticket\n\nThe ``uturn`` template tag will first determine the actual URL you want to link\nto, exactly like the default ``url`` template tag would. But the ``uturn`` tag\nwill also add the *current* request path as the value for the ``next``\nparameter::\n\n Add ticket\n\nClicking this link on the project page and adding a ticket will get you\nredirected to the ``/projects/`` URL *if you add the correct field to your\nform*.\n\n\nPassing through forms\n^^^^^^^^^^^^^^^^^^^^^\n\nThe easy way to add the parameter to your forms is by adding the\n``uturn_param`` template tag inside your form tags. If you're using\nDjango's builtin CSRF protection, you'll already have something like this::\n\n
\n {{ form.as_p }}\n {% csrf_token %}\n \n
\n\nChange that to this::\n\n
\n {{ form.as_p }}\n {% csrf_token %}\n {% uturn_param %}\n \n
\n\nDon't worry if you *don't* want to use ``next`` as the parameter. You can\nspecify a custom parameter name with the ``UTURN_REDIRECT_PARAM`` setting. And\nif you want to redirect to other domains, you can specify those domains with\nthe ``UTURN_ALLOWED_HOSTS`` setting. Otherwise requests to redirect to other\ndomains will be ignored.\n\n\nOverriding URLs in templates\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThere's just one more thing we need to change: the *cancel* link on your form::\n\n
\n {{ form.as_p }}\n {% csrf_token %}{% uturn_param %}\n or\n cancel\n
\n\nThat link should point to the project page when applicable. Use the\n``defaulturl`` tag to accomplish this::\n\n {% load uturn %}\n
\n {{ form.as_p }}\n {% csrf_token %}{% uturn_param %}\n or\n cancel\n
\n\nThe ``defaulturl`` tag will default to standard ``url`` tag behavior and use\nthe ``next`` value when available. Here's what your form would look like from\nthe ticket list page (with or without the ``next`` parameter)::\n\n
\n ...\n or\n cancel\n
\n\nAnd here's what that same form would look like when you reached it from the\nproject page::\n\n
\n ...\n or\n cancel\n
\n\n----\n\nChangelog\n---------\n\nv0.3.0\n^^^^^^\nDrop support for Django versions prior to 1.4 and verify support for Django\n1.5 and 1.6.\n\nv0.2.4\n^^^^^^\nMake the ``uturn`` template tag work a bit more as expected.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/roam/django-uturn", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-uturn", "package_url": "https://pypi.org/project/django-uturn/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-uturn/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/roam/django-uturn" }, "release_url": "https://pypi.org/project/django-uturn/0.3.1/", "requires_dist": null, "requires_python": null, "summary": "Overriding redirects in Django, to return where you came from", "version": "0.3.1" }, "last_serial": 913829, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "20bcb42dc7b400b156f63bc56d58fb97", "sha256": "0e266385be51fe77b25cf6bd9b8270cdb25a5b34fa24896dc1e075c58f5dc8e6" }, "downloads": -1, "filename": "django-uturn-0.1.0.tar.gz", "has_sig": false, "md5_digest": "20bcb42dc7b400b156f63bc56d58fb97", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6777, "upload_time": "2012-06-18T22:27:33", "url": "https://files.pythonhosted.org/packages/c6/af/f8915122e8a342aacb641d746a61c0ecad2d26eff2e8dae29da22b3b71c0/django-uturn-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "c751163fd50cebfc7196748e2d6e9f02", "sha256": "4e5e5b20bca15fcccd618019b760105a7636ed7356a5dfc907bbf98d34858479" }, "downloads": -1, "filename": "django-uturn-0.2.0.tar.gz", "has_sig": false, "md5_digest": "c751163fd50cebfc7196748e2d6e9f02", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7147, "upload_time": "2012-06-19T22:31:36", "url": "https://files.pythonhosted.org/packages/66/92/31006a93a90ab2670954a112ead297c47c1e780d32450a95404590d21016/django-uturn-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "f5f102d98dde05830c1f90bddb1284db", "sha256": "2512d42e871c04924344a56d7117328d55ca94b842943c7936555d05a5078f77" }, "downloads": -1, "filename": "django-uturn-0.2.1.tar.gz", "has_sig": false, "md5_digest": "f5f102d98dde05830c1f90bddb1284db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7158, "upload_time": "2012-08-03T15:29:32", "url": "https://files.pythonhosted.org/packages/d8/e5/8cbae9b51abffb4f594d9d18f5421bcc49be8d130a6d53e6b7ff60493ee5/django-uturn-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "6e0e1933c5ed71d5cf8a3c745dac0da6", "sha256": "8b0fb64c5786cb68fbd5c86b0265697e8a99ddaa2bf05a11ba3b8a7895f207f3" }, "downloads": -1, "filename": "django-uturn-0.2.2.tar.gz", "has_sig": false, "md5_digest": "6e0e1933c5ed71d5cf8a3c745dac0da6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7180, "upload_time": "2012-08-14T18:29:17", "url": "https://files.pythonhosted.org/packages/11/da/22b8f83280129728380d24cca2c17dd05280e7e51cc7fdf40e6d7cb78940/django-uturn-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "c13ebbb7082c2633be5fa6712c40a05e", "sha256": "c07e2c329b9354b4a921aeda51fdb68d0cf6d4e8e52d5f4d4ee812950fc2de2b" }, "downloads": -1, "filename": "django-uturn-0.2.3.tar.gz", "has_sig": false, "md5_digest": "c13ebbb7082c2633be5fa6712c40a05e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7227, "upload_time": "2012-08-25T12:52:04", "url": "https://files.pythonhosted.org/packages/c9/a5/d4d719476c8fd6a4b5db0b6b6464edafc8d664495ebbe9d507e62698998c/django-uturn-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "c9df20cbe467011894d2b88d5d1fd83c", "sha256": "157446af08e5df490ddb1dc5e029483d1809d359691caa3b0b169ed0fe51e56c" }, "downloads": -1, "filename": "django-uturn-0.2.4.tar.gz", "has_sig": false, "md5_digest": "c9df20cbe467011894d2b88d5d1fd83c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7277, "upload_time": "2012-08-30T05:53:27", "url": "https://files.pythonhosted.org/packages/e6/03/1a60e1d410de73aadafef0c6ddfb599a7eed80cc1ecaeb6ba87def0e6930/django-uturn-0.2.4.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "c779fcb33a06488705501c23474ee50b", "sha256": "aea5a0fa885453f1808ab6664614866e464b9350cf595a63515efc2804b5ae39" }, "downloads": -1, "filename": "django_uturn-0.3.0-py27-none-any.whl", "has_sig": false, "md5_digest": "c779fcb33a06488705501c23474ee50b", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 11793, "upload_time": "2013-11-06T22:13:06", "url": "https://files.pythonhosted.org/packages/6d/91/a3002b9057bbef076c03e31e19e4e9bea34b60b9297c8b9b9bb4e62b8b73/django_uturn-0.3.0-py27-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3209d2a35918450cb59d418d9572e335", "sha256": "87811928374d65aa6f0bcdc65839460ed78690ac8cb3b767effa8e55af2d0b85" }, "downloads": -1, "filename": "django-uturn-0.3.0.tar.gz", "has_sig": false, "md5_digest": "3209d2a35918450cb59d418d9572e335", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7730, "upload_time": "2013-11-06T22:12:46", "url": "https://files.pythonhosted.org/packages/76/1c/b8c9e56835d2d92b6c797c1b8e84ef84594c9f2dadb02eede3c8ee7373b9/django-uturn-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "aa1c45350281aa9edbba261426067162", "sha256": "616d634d912528c57442c3d758058deae878c0f7b3cdb744f7608f3a46df1385" }, "downloads": -1, "filename": "django_uturn-0.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "aa1c45350281aa9edbba261426067162", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 12453, "upload_time": "2013-11-07T20:23:33", "url": "https://files.pythonhosted.org/packages/5c/f4/2ec5a07e67276629994218d6e46036f222532bd8f368deb8037dcef93f2c/django_uturn-0.3.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "bd3e3a73de34117f7f6649c01f5c5dfc", "sha256": "f9afd68fff52acb7b96061b5c82562f0d621ff9ad514b8bc1cf491cc3cd9cffb" }, "downloads": -1, "filename": "django-uturn-0.3.1.tar.gz", "has_sig": false, "md5_digest": "bd3e3a73de34117f7f6649c01f5c5dfc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8030, "upload_time": "2013-11-07T20:23:18", "url": "https://files.pythonhosted.org/packages/41/60/366673f3a2648062fc6dcafc9b38dd4c2006ed8fe46180a63228b77fa60e/django-uturn-0.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "aa1c45350281aa9edbba261426067162", "sha256": "616d634d912528c57442c3d758058deae878c0f7b3cdb744f7608f3a46df1385" }, "downloads": -1, "filename": "django_uturn-0.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "aa1c45350281aa9edbba261426067162", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 12453, "upload_time": "2013-11-07T20:23:33", "url": "https://files.pythonhosted.org/packages/5c/f4/2ec5a07e67276629994218d6e46036f222532bd8f368deb8037dcef93f2c/django_uturn-0.3.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "bd3e3a73de34117f7f6649c01f5c5dfc", "sha256": "f9afd68fff52acb7b96061b5c82562f0d621ff9ad514b8bc1cf491cc3cd9cffb" }, "downloads": -1, "filename": "django-uturn-0.3.1.tar.gz", "has_sig": false, "md5_digest": "bd3e3a73de34117f7f6649c01f5c5dfc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8030, "upload_time": "2013-11-07T20:23:18", "url": "https://files.pythonhosted.org/packages/41/60/366673f3a2648062fc6dcafc9b38dd4c2006ed8fe46180a63228b77fa60e/django-uturn-0.3.1.tar.gz" } ] }