﻿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
15537	allow the login_url accept a relative path	lanyjie	nobody	"In the development version, the login_required decorator accepts a parameter named login_url:

{{{
@login_required(login_url='/accounts/login/')
def my_view(request): ...
}}}

Sometimes, the login_url may depend on the request path (for example, when the path already implies the login name -- the name may even not be known to the user, and the login page would only ask for a password). Allowing a relative path would be great in this case:

{{{
@login_required(login_url='login.html')
def my_view(request): ...
}}}

To implement this, simply insert an one-way if-statement into the decorated view function before using login_url:

{{{
def login_required(login_url=None, ...):
   ...
   def decorated_view(request, *args, **kwds):
      ...
      if login_url and not login_url.startswith('/'):
         login_url = request.path + login_url
      ...
   return decorated_view
}}}

A more general approach is to have login_url accept a callable that takes the request as a parameter and returns an absolute path; however, I don't have a use case for that yet."		closed	contrib.auth	1.3-beta		wontfix	relative path login_url		Unreviewed	1	0	0	0	0	0
