On Jul 7, 12:01 pm, Graham Dumpleton <
graham.dumple...@gmail.com>
wrote:
> On Jul 7, 11:47 am, Oleg Lomaka <
oleg.lom...@gmail.com> wrote:
>
> > Exactly for your case, you may set LOGIN_URL point to '/myapp/accounts/login/', but 'next' parameter still left inaccurate.
http://docs.djangoproject.com/en/dev/ref/settings/#login-url
>
> As far as I am concerned, Django should be inserting SCRIPT_NAME, ie.,
> the mount point, automatically in front of the default value of
> LOGIN_URL and you shouldn't need to override it. In other words, it
> would make sense that partial URL paths in settings.py should always
> be relative to the mount point.
>
> But then, it may never have been logically right because of mod_python
> brokeness in the past with handling mount point.
>
> It would be nice if core developer could clear this issue up.
Oh well, looks like it doesn't do it in way that I thought would be
sane way of doing it. :-(
def logout_then_login(request, login_url=None):
"Logs out the user if he is logged in. Then redirects to the log-
in page."
if not login_url:
login_url = settings.LOGIN_URL
return logout(request, login_url)
def redirect_to_login(next, login_url=None,
redirect_field_name=REDIRECT_FIELD_NAME):
"Redirects the user to the login page, passing the given 'next'
page"
if not login_url:
login_url = settings.LOGIN_URL
return HttpResponseRedirect('%s?%s=%s' % (login_url,
urlquote(redirect_field_name), urlquote(next)))
Ie., uses raw settings value instead of putting SCRIPT_NAME in front
by the look of it.
BTW, aren't Location response headers for redirects meant to be a full
'http' or 'https' address? I know browsers will usually work if not,
but thought the standards required that they were.
Quoting wikipedia:
"""
According to the HTTP protocol, the Location header must contain an
absolute URI[5]. When redirecting from one page to another within the
same site, it is a common mistake to use a relative URI. As a result
most browsers tolerate relative URIs in the Location header, but some
browsers display a warning to the end user.
"""
Or am I confusing 'absolute' and that it doesn't have to have 'http://
host' in it?
Graham
> > For more general case, to make working not only auth urls, look at those snippets:
> > -
http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango-comment section, look around URL_PREFIX keyword;