vovkd / js-csrf-django

Simple javascript to make easy to make POST with AJAX using Django. Based on django documentation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

js-csrf-django

Simple javascript to make easy to make POST with AJAX using Django. Based on django documentation.

Installation

  1. Add CsrfViewMiddleware in your MIDDLEWARE_CLASSES in settings.py file of your project.
MIDDLEWARE_CLASSES = (
	...
	'django.middleware.csrf.CsrfViewMiddleware',
	...
)
  1. Add the javascript file https://raw.github.com/ebertti/js-csrf-django/master/csrf.js in the head of your html page, rather in yout base.html, after jQuery file:
	<html>
		<head>
			<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
			<scripr scr="https://raw.github.com/ebertti/js-csrf-django/master/csrf.js"></script>
		</head>
	</html>
  1. Now you can make your AJAX request using POST.

About

Simple javascript to make easy to make POST with AJAX using Django. Based on django documentation


Languages

Language:JavaScript 100.0%