TastyPie の初心者です。私は非常に単純なリソースを持っており、次の方法で obj_create メソッドをオーバーライドしています。
Ajax 呼び出し :-
var data2 ={
"crave": data1,
"uid": "100",
"access_token": "AAA"
};
$.ajax({
url: "http://localhost:8000/restapi/v1/icrave/",
type: 'POST',
data: data2,
contentType: 'application/json',
dataType: 'json',
success: function (res) {
console.log(res);
},
});
リソースで
class IcravesResource(ModelResource):
person = fields.ForeignKey(UserResource, 'person')
class Meta:
queryset = Icrave.objects.filter(anonymous_or_not = False,is_active = True).order_by('-datetime')
resource_name = "icrave"
allowed_methods = ['get','post']
authentication = GetAuthentication()
authorization = GetAuthorization()
def obj_create(self,bundle,request=None, **kwargs):
print "Check if code reached here !!!"
return super( IcravesResource, self ).obj_create( self, bundle, request, **kwargs )
コードがここまで来ていません。私は何を間違っていますか?認証と認証を確認しましたが、どちらも true を返しています。この問題をデバッグするにはどうすればよいですか?