# views.py
def login(request):
login = None
if request.user.is_authenticated(): # check if user has login
login = True
else:
login = False
return render_to_response('polls/login.html', {'title': 'Login Logout Page', 'login':login})
login = None
if request.user.is_authenticated(): # check if user has login
login = True
else:
login = False
return render_to_response('polls/login.html', {'title': 'Login Logout Page', 'login':login})
def loginprocess(request):
from django.contrib.auth import authenticate, login, logout
from django.http import HttpResponseRedirect
from django.contrib.auth import authenticate, login, logout
from django.http import HttpResponseRedirect
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user) # login script
return HttpResponseRedirect('http://localhost:8000/login')
else:
return render_to_response('polls/login.html', {'title': 'Disabled Account'})
else:
return render_to_response('polls/login.html', {'title': 'Not Registered Account'})
def logout(request):
from django.contrib.auth import logout
from django.http import HttpResponseRedirect
logout(request)
return HttpResponseRedirect('http://localhost:8000')
No comments:
Post a Comment