I have a django app but I having problems with my login views and logout views. I do not have a html template designated to handle user login/logout view.
Django project is configured as follows:
Using Django Template Language and Template inheritance. The login form is on the base template on other templates extends from this base template.
All my login attempts result in some of the views rendering the user info (username to welcome user back) while other views rendering the page as if the user is an anonymous user. If I try to login in again I get an error page stating that there is a missing csrf token or incorrect. Adding to this I have identified many instances where I have tried to logout and it does not seem to log me out because it is still showing the last user login info. For my base template I have hard coded the form (meaning not using Django Form class).
Can You identify the possible fault in how i am implementing the login and logout views?
Here is a copy of my login and logout views
def members_login(request):
if request.method == 'POST':
password = request.POST['password']
username = request.POST['username']
user = authenticate(username=username,password=password)
if user is not None:
if user.is_active:
login(request,user)
return redirect('members:index')
else:
#inactive users required to re-register
return redirect('members:index')
else:
#no account required to register to create one
return redirect('members:register')
else:
#test if login is a regular get request then redirect
return HttpResponseRedirect(reverse('members:index'))
def members_logout(request):
logout(request)
return redirect('members:index')