def login2(request): m = Login.objects.all() if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): username = form.cleaned_data['username'] password1 = form.cleaned_data['password1'] password2 = form.cleaned_data['password2'] name = form.cleaned_data['name'] email = form.cleaned_data['email'] idnumber = form.cleaned_data['idnumber'] home = form.cleaned_data['home'] if password1 != password2: return render(request, 'login2.html') else: login = Login() login.username = username login.password1 = password1 login.password2 = password2 login.name = name login.email = email login.idnumber = idnumber login.home = home login.save() #return render(request, 'login2.html') return render_to_response('login2.html', {'m': m}) else: return HttpResponse("error!") else: form = LoginForm() return render_to_response('login2.html', {'m': m})