I am running django server and when I do a post I get a 403 message. My question is that to make a json call as shown below should I be running apache? Or else, what am I doing wrong?
In the html page I have included the latest jquery file only.
var snddata = {};
snddata["username"] = username;
snddata["firstname"] = firstname;
snddata["lastname"] = lastname;
snddata["usertype"] = $("#usertype").val();
snddata["address"] = address;
snddata["emailid"] = emailid;
snddata["empid"] = empid;
$.post("/home/", snddata,
function callbackHandler(data, textstatus)
{
if (data.status == 1)
{
alert("User added successfully");
}
else
{
alert(data.msg);
}
},
"json"
);
Django has a csrf protection and you must to put “csrfmiddlewaretoken” for every POST request.
Try to add this line of code:
You must insert this tag in your form, wich returns a hidden input field with csrf_token: