Skip to content

Instantly share code, notes, and snippets.

@guillaumepiot
Created October 23, 2012 15:28
Show Gist options
  • Star 26 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save guillaumepiot/3939452 to your computer and use it in GitHub Desktop.
Save guillaumepiot/3939452 to your computer and use it in GitHub Desktop.
ANGULARJS - Django CSRF Token header setup
var myApp = angular.module('myApp').config(function($httpProvider) {
$httpProvider.defaults.headers.post['X-CSRFToken'] = $('input[name=csrfmiddlewaretoken]').val();
});
@pasupulaphani
Copy link

Just put together a small lib just to make easy to use. Similar concept. https://github.com/pasupulaphani/angular-csrf-cross-domain

@budescode
Copy link

Where do I place this code.?

@guillaumepiot
Copy link
Author

I can't remember sorry, haven't worked with Angular in years...

@guillaumepiot
Copy link
Author

Looks like it's when you initialize your app, which is the html element with tag ng-app="myApp"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment