0
我用angularJS
$http
將數據發送到Django和方法是POST
這是我controller.js
Django的接受數據從angularJS無效
registerApp.controller('registerCtrl', function($scope, $http) {
$scope.submitRegisterForm = function() {
if ($scope.registerForm.$valid) {
console.log($scope.user);
$http({
method: 'POST',
url: '.',
data: $scope.user,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
} else {
return console.log(3333);
}
};
});
這是我views.py
在Django
if request.method == 'POST':
print request.POST
但打印結果是
<QueryDict: {u'{"username":"bob","password1":"123123","password2":"123123","email":"[email protected]"}': [u'']}>
爲什麼數據是字典的關鍵?
而且是[u'']
來自?
它的成功,THX :) – nataila