Thankyou Wongo Bongo! Your solution was spot on correct. It came down to
one line of code that I modified that was the problem.
login_data = {'username':'jim', 'password':'beam',
'this_is_the_login_form':'1', 'csrfmiddlewaretoken':csrftoken}
You gave me the correct line, however the, 'this_is_the_login_form':'1' I
thought you were giving me a generic form name to be replaced with my form
name, however 'this_is_the_login_form' is the correct form name.
This is where my inexperince has shown through. How did you know that that
was the name of the form? When I went to django.contrib.auth.forms, it
seemed the form name was AuthenticationForm, and when I used view source in
a browser it looked like the form was named login-form. How could one know
the form was named 'this_is_the_login_form'?
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.