示例#1
0
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})
示例#2
0
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})
示例#3
0
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})
示例#4
0
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})
示例#5
0
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)