ajax - django login through javascript -
this question has answer here:
- django csrf check failing ajax post request 15 answers
i attempting use django website. implemented login using code:7
user_django = authenticate(username=email, password=passw) login(request, user_django)
which using django rest framework working. when use ajax request think not storing cookies. using django function check if user logged in:
if request.user.is_authenticated(): return response('1') else: return response('0')
but return 0. have special on client side store login information?
my javascript login:
function userlogin(){ var user_email = $('#login_user_email').val(); var user_pwd = $('#login_user_pwd').val(); var data = {email:user_email, password:user_pwd}; $.ajax(prefix+ 'userlogin/', { success: function(output, status, xhr){ $('#login_btn').click(); }, data: data, type: 'post' }); }
this familiar problem me , might duplicate other question on so,
look @ these, find solution .
Comments
Post a Comment