angular-django-csrf

Angular $http interceptor that adds CSRF token for Django


Keywords
angular, django, csrf, interceptor, $http
License
MIT
Install
bower install angular-django-csrf

Documentation

angular-django-csrf

creates an AngularJS $http interceptor which adds the CSRF token for Django use

Install

$ bower install angular-django-csrf

Usage

  • Make sure the angular-django-csrf.js file is added to your index.html
  • Add the angularDjangoCsrf module to the list of your app dependencies
  • Ensure that you have ngCookies loaded in your app as well

Add a <script> to your index.html:

<script src="/bower_components/angular-cookies/angular-cookies.js"></script>
<script src="/bower_components/angular-django-csrf/angular-django-csrf.js"></script>

And add angularDjangoCsrf as a dependency for your app:

angular.module('myApp', ['ngCookies', 'angularDjangoCsrf']);

Dependencies

ngCookies is a required dependency of this module.