verir ama bana 500 (dahili sunucu hatası) verir.Mesaj isteği 500 iç sunucu hatası
Bu benim açısal dosyasıdır:
var app = angular.module('myApp', [])
app.config(function($interpolateProvider, $httpProvider){
$interpolateProvider.startSymbol('{[{').endSymbol('}]}');
$httpProvider.defaults.xsrfCookieName = 'csrftoken';
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
});
app.controller('myCtrl', ['$scope', '$http', function ($scope, $http){
var details = {
length : $scope.length,
breadth : $scope.breadth,
height : $scope.height,
weight : $scope.weight,
country : $scope.country,
itemType : $scope.itemType
}
var theJSON = JSON.stringify(details);
$http({
method : 'POST',
url : '/interApp/calc/',
data : $.param(theJSON),
headers : {'Content-Type': 'data:application/json;charset=utf-8;'+ encodeURIComponent(theJSON) },
}).success(function(data) {
console.log(theJSON);
})
}
}])
ve bu django görünümüdür:
from django.http import Http404
from django.http import HttpResponse
from django.shortcuts import render_to_response
from .models import Countries,CourierCompany,Zones,Weight
from django.core.context_processors import csrf
def rate_calculator(request):
if request.method == "POST":
////code goes here...
ve benim urls.py dosyasıdır:
from django.conf.urls import url
from . import CostView
urlpatterns = [
url(r'^calc/', views1.rate_calculator, name='rate_calculator'),
]
ama bana verir konsol penceresinde hata:
SONRASI http://127.0.0.1:8000/interApp/calc/ 500 (Dahili sunucu hatası) json ederek Django işlevi veri okumak için
Bence, bunu kullanarak bunu elde Yayınınız isteği verileri var eğer alışkanlık .. Hatası ile talep, bu POST izlerseniz ı may düşünüyorum beni tam hata ne olduğunu bildirmek 'veriler: - ayarlarında' DEBUG = TRUE ayarlamak ve hatayı gözlemlemek theJSON, 'başarısız olursa olsun –
deneyin yeterlidir. Veya, kurulum ayarlarınız varsa, hatanın ne olduğunu araştırın. –
aynı hata da var postacı kullanarak veri göndermek ve görmek için orada – alecxe