Answer the question
In order to leave comments, you need to log in
Why is the login not working?
function ajax_auth(e) {
var url = 'login';
e.preventDefault();
$.ajax({
url:url,
data:{
username: $("#id_username").val(),
password: $("#id_password").val(),
csrfmiddlewaretoken: '{{ csrf_token }}'
},
type: 'POST',
success: function () {
}
})
}
def login_user(request):
if request.user.is_authenticated():
return redirect('/')
if request.is_ajax():
if request.method == 'POST':
user = auth.authenticate(username=request.POST.get('username'), password=request.POST.get('password'))
if user is not None:
auth.login(request, user)
return redirect('/')
return render(request, 'login/login.html', locals())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question