0
我试图张贴在Django采用了棱角分明$ http.post方法的数据,我想知道我将如何访问,在我的Django的看法参数值: -如何在Django看法访问角度传递的参数
这里我的controller.js
var nameSpace = angular.module("ajax", ['ngCookies']);
nameSpace.controller("MyFormCtrl", ['$scope', '$http', '$cookies',
function ($scope, $http, $cookies) {
$http.defaults.headers.post['Content-Type'] = 'application/json';
// To send the csrf code.
$http.defaults.headers.post['X-CSRFToken'] = $cookies.get('csrftoken');
// This function is called when the form is submitted.
$scope.submit = function ($event) {
// Prevent page reload.
$event.preventDefault();
// Send the data.
var in_data = jQuery.param({'content': $scope.card.content,'csrfmiddlewaretoken': $cookies.csrftoken});
$http.post('add_card/', in_data)
.then(function(json) {
// Reset the form in case of success.
console.log(json.data);
$scope.card = angular.copy({});
});
}
}]);
这里是我试图访问这些在我看来功能: -
card.content =request.POST.get('content')
其中卡是我的模型的对象,但我正在逐渐NameError:名字“CON帐篷'没有定义,请帮助我!
我应该改变我的views.py也?? @阿甘 –
@VinitRaj没有必要改变view.py文件 –