def auth_form(request): if request.POST: form = AuthForm(request.POST) if form.is_valid(): l = form.cleaned_data['login'] p = form.cleaned_data['password'] res = Users.objects.filter(login=l, password=p, is_deleted="0", is_blocked="0") if res: return render(request, 'auth/login.html', {'res':"Авторизация успешна!"}) else: return render(request, 'auth/login.html', {'forms':form,'error':'Логин/пароль введен неверно!'}) else: form = AuthForm() return render(request, 'auth/login.html', {'forms':form}) 

After successful authorization, how to redirect to www.yandex.ru

    3 answers 3

    Simple redirect. With examples.

     from django.http import HttpResponseRedirect .... def some(request): ... return HttpResponseRedirect('http://yandex.ru/') 
       from django.shortcuts import redirect def my_view(request): ... if res: return redirect('http://yandex.ru/') else: 

      Documentation

        Why manually take a model object if there is a built-in mechanism in jango that records an object in a session? In addition, all the django passwords keep the cached ones, and you transfer the "simple" ones - you will never make a valid selection from the database.
        If it is already "in the forehead" - then look at the redirect () function in the documentation (it seems so called), but in general I would advise to get acquainted with this .

        • I can't use contrib.auth. There is a client base, you need to implement the technology cisco ISG authorization through the portal, this is done for WIFI. Maybe in something I'm wrong. - avdoshkin