コード例 #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, "generic_form.html", {"form" : form})
コード例 #2
0
ファイル: views.py プロジェクト: LetishaB/baking
def loguserin(request):
    loginform = LoginForm()
    if request.method == 'POST':
        loginform = LoginForm(request.POST)
        if loginform.is_valid():
            user = authenticate(username=request.POST["user_name"], password=request.POST["password"])
            if user is not None:
                if user.is_active:
                    login(request, user)
                    return HttpResponseRedirect('/sharerecipes')
    categories = Category.objects.all().order_by("name")
    return render(request, "login.html", {"loginform": loginform, "categories":categories})
コード例 #3
0
ファイル: views.py プロジェクト: Cesaly/recipebox
def loginview(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', '/'))
    form = LoginForm()
    return render(request, 'generic_form.html', {'form': form})
コード例 #4
0
def loginview(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('homepage')))
    form = LoginForm()
    return render(request, 'author_form.html', {'form': form})
コード例 #5
0
def loguserin(request):
    loginform = LoginForm()
    if request.method == 'POST':
        loginform = LoginForm(request.POST)
        if loginform.is_valid():
            user = authenticate(username=request.POST["user_name"],
                                password=request.POST["password"])
            if user is not None:
                if user.is_active:
                    login(request, user)
                    return HttpResponseRedirect('/sharerecipes')
    categories = Category.objects.all().order_by("name")
    return render(request, "login.html", {
        "loginform": loginform,
        "categories": categories
    })