I’m using Django standard auth. / login having the following loc in my /urls.py.
(r'^$', 'django.contrib.auth.views.login', {'template_name': 'home.html', }),
Login works fine if the user calls http://www.myapp.com and login redirects to LOGIN_REDIRECT_URL = ‘/pm/po/my/’ (www.myapp.com/pm/po/my/) defined in the settings.py.
The session is not killed (= user is not logged out) if the user closes the browser tab, leaving open the browser. Which is also fine.
However if the user then opens a new tab and goes to http://www.myapp.com the login view is shown again, while being the user already logged in. Here I want the user have redirected to http://www.myapp.com/pm/po/my/ .
How can I achieve this?
I tried it adding the following line:
(r'^$', 'myapp.project_management.views.projects'),
(r'^$', 'django.contrib.auth.views.login', {'template_name': 'home.html', }),
However this leads to the following error message: “This webpage has a redirect loop”
–Solution–
urls.py:
(r'^$', 'myapp.project_management.views.my_projects'),
(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'home.html', }),
settings.py
LOGIN_URL = '/login'
Don’t make the home URL point to the login page. Instead, use the
login_requireddecorator to redirect non-logged in users to the login page as necessary.