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文件 –