ajax - django login through javascript -


this question has answer here:

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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -