def login_view(request): if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): data = form.cleaned_data user = authenticate(request, username=data.get('username'), password=data.get('password')) if user: login(request, user) return HttpResponseRedirect(request.GET.get('next', reverse("homepage"))) form = LoginForm() return render(request, "basic.html", {"form": form})
def login_view(request): if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): data = form.cleaned_data user = authenticate(request, username=data.get("username"), password=data.get("password")) if user: login(request, user) return HttpResponseRedirect(reverse("home_page")) form = LoginForm() return render(request, "generic_form.html", {"form" : form})
def login_view(request): if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): data = form.cleaned_data user = authenticate(request, username=data['username'], password=data['password']) if user: login(request, user) return HttpResponseRedirect( request.GET.get('next', reverse('home'))) form = LoginForm() return render(request, 'sign_up_form.html', {"form": form})
def login_view(request): if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): data = form.cleaned_data user = authenticate(request, username=data["username"], password=data["password"]) if user: login(request, user) return HttpResponseRedirect( request.GET.get("next", reverse("home"))) form = LoginForm() return render(request, "login.html", {"form": form})
def loginview(request): html = 'login.html' context = {} if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): data = form.cleaned_data user = authenticate( request, username=data['username'], password=data['password'], ) if user: login(request, user) return HttpResponseRedirect( request.GET.get(next, reverse('home')) ) else: context['login_form'] = form else: form = LoginForm() context['login_form'] = form return render(request, html, context)