I want to create a simple Django authentication (register/login/logout) but I have problems. if complete login successfully then app go to next page with name mypage because I have define in my settings.py that line : LOGIN_REDIRECT_URL = '/mypage'.
but in the new page user is not authenticated user(my user stay authenticated only in the "/login"and"/register"page but not in home and mypage )
any idea why I have wrong ?
here the code :
urls.py
url(r'^$', views.home), url(r'^mypage/$', views.mypage), url(r'^login/$', views.login, {'template_name': 'login.html', 'authentication_form': LoginForm}), url(r'^logout/$', views.logout, {'next_page': '/login/'}), url(r'^register/$', views.register), url(r'^register/success/$', views.register_success) views.py
def home(request): return render_to_response('home.html') def mypage(request): return render_to_response('home2.html') settings.py
LOGIN_REDIRECT_URL = '/mypage' html 1 :
{% if user.is_authenticated %} <li> <a href="/logout">LogOut</a> </li> {% else %} <li> <a href="/login">Login</a> </li> {% endif %} html 2 :
{% if user.is_authenticated %} <a href="#" class="lg">Start</a> {% else %} <p>Please Login to start</p> {% endif %}