﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
19551	Enable dynamic redirect after login, by setting LOGIN_REDIRECT_URL to a callable	Chris Wilson	nobody	"It's quite a common requirement to redirect to a different page after login, for example depending on some information about the user, or the time of day, etc:

* http://stackoverflow.com/questions/1608261/django-login-redirect-url-with-dynamic-value
* http://stackoverflow.com/questions/3842075/conditional-login-redirect-in-django?rq=1

This involves:

* either rewriting the login() view, which may be a security risk, as it's easy to get wrong, and definitely not DRY;
* or doing a second redirect from the landing page after login which is inefficient and slow.

I think it would be a very simple change to allow `LOGIN_REDIRECT_URL` to point to a callable, in `django.contrib.auth.views.login`:

{{{
             if not redirect_to:
                 redirect_to = settings.LOGIN_REDIRECT_URL
+            if callable(redirect_to):
+                redirect_to = redirect_to(request, form.get_user())
}}}"	New feature	closed	contrib.auth		Normal	duplicate			Unreviewed	0	0	0	0	0	0
