我的观点 。
class EventRVSPResource(ModelResource):
event = fields.ForeignKey(EventResource, 'event')
created_by = fields.ForeignKey(UserResource, 'created_by')
class Meta:
queryset = EventRsvp.objects.all()
authorization = Authorization()
resource_name = 'eventrvsp'
filtering = {
'event':ALL_WITH_RELATIONS,
'created_by': ALL,
}
但是使用 curl 发送数据工作正常。它显示 201
curl --dump-header - -H "Content-Type: application/json" -X POST --data '{"created_by": "/mobapp/api/v1/user/1/","event": "/mobapp/api/v1/eventlist/5/","notes": "Going","past_status": "DG","status": "Y"}' http://192.168.1.8:9000/mobapp/api/v1/eventrvsp/
我对 django-tastypie 的 Http 请求。但它仍然显示错误。我不知道它有什么问题
var url = "http://192.168.1.8:9000/mobapp/api/v1/eventrvsp/";
var client = Ti.Network.createHTTPClient({
// function called when the response data is available
onload : function(e) {
Ti.API.info("Received text: " + this.responseText);
alert('success');
},
// function called when an error occurs, including a timeout
onerror : function(e) {
Ti.API.debug();
alert(e.error);
},
timeout : 5000 // in milliseconds
});
// Prepare the connection.
client.open("POST", url);
// Send the request.
client.send({"created_by": "/mobapp/api/v1/user/1/","event": "/mobapp/api/v1/eventlist/4/","notes": "Going","past_status": "DG","status": "Y"});