I feel as if I'm getting closer, yet haven't successfully  logged in yet. I 
have added in the missing key. I went to the django.contrib.auth.forms to 
find the name of the form that gets submitted in the login page. It seems 
to be called AuthenticationForm.

import requests
login_url = "http://192.168.0.21/admin/login/";


client = requests.session()
client.get(login_url)


csrftoken = client.cookies['csrftoken']


login_data = {'username':'jim', 'password':'beam', 
'AuthenticationForm':'1', 'csrfmiddlewaretoken':csrftoken}


r = client.post(login_url, data=login_data)


Basically after I do this from the python shell, I use another machine to 
log into the admin page and look at user logins, and the user is not logged 
in. Not sure how to proceed.


On Monday, August 19, 2013 12:13:21 AM UTC-4, WongoBongo wrote:
>
> You were missing a key. The following works on my machine.
>
> K
>
> ---
>
>
> import requests
> login_url = "http://192.168.0.21/admin/login/";
>
>
> client = requests.session()
> client.get(login_url)
>
>
> csrftoken = client.cookies['csrftoken']
>
>
> login_data = {'username':'jim', 'password':'beam', 
> 'this_is_the_login_form':'1', 'csrfmiddlewaretoken':csrftoken}
>
>
> r = client.post(login_url, data=login_data)
>
>
> target_url = "http://192.168.0.21/admin/auth/user/";
> t = client.get(target_url)
>
>
> 'Select user to change' in t.text # True 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to