﻿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
18161	Redirection after successful login is not working properly	wolfgang.doll@…	Florian Apolloner	"Suppose the following situation:

We have the following url config in `urls.py`

{{{
url(r'^tabview/(?P<page>\d+)/$', 'tabview.views.tabview', name='tabview-tabview'),
}}}

We have a view with the following signature:

{{{
@login_required
def tabview(request, page='1'):
    pass
}}}

We have this settings in `settings.py`

{{{
LOGIN_URL = '/admin/login'
LOGOUT_URL = '/admin/logout'
}}}

We are not logged in yet.

Now we try to request `localhost:8000/tabview/1/`.[[BR]]
We get a redirect to `localhost:8000/admin/login/?next=tabview/1/`. This is ok.[[BR]]
We do a successful login and get a redirect to `localhost:8000/admin/login/?next=tabview/1/`.[[BR]]
This is a wrong behaviour !

Expected (According the [https://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.views.login Django Doc]) is a redirect to `localhost:8000/tabview/1/`.

After some investigation we found the reason:

In `django.contrib.auth.views.login` the new calculated `redirect_field_name` inside `context` is overwritten by the old `redirect_field_name` in `extra_context`:

{{{
context = {
    'form': form,
    redirect_field_name: redirect_to,
    'site': current_site,
    'site_name': current_site.name,
}
if extra_context is not None:
    context.update(extra_context)
}}}

With this change we can fix this issue to the expected behaviour:

{{{
context = extra_context or {}
context.update( 
    {
        'form': form,
        redirect_field_name: redirect_to,
        'site': current_site,
        'site_name': current_site.name,
    }
)
}}}"	Bug	closed	contrib.admin	1.4	Normal	wontfix		Florian Apolloner	Accepted	1	0	1	0	1	0
