https://docs.djangoproject.com/en/1.3/ref/contrib/csrf/#exceptions
I use this on views that my mobile apps post to.
--
Greg Donald
Get the login webpage and parse the csrf token into the data shell variable.
$ data=$(curl -s -c cookies.txt http://www.crowdsourcingnutritionfacts.info/accounts/login/ | grep -o "name=['\"]csrfmiddlewaretoken['\"] value=['\"][^'\"]*" | sed -e "s/name='//" -e "s/' value='/=/")\&username=user name\&password=password
Log in to the website.
$ curl -b cookies.txt -c cookies.txt -d $data -X POST -H 'Content-Type: application/x-www-form-urlencoded' http://www.crowdsourcingnutritionfacts.info/accounts/login/
Get brands containing the search term "ea".
$ curl -b cookies.txt http://www.crowdsourcingnutritionfacts.info/api/auto-complete/brand/?term=ea