0

I use Tastypie for Django's API. but it returns error. my code is bellow.

$.ajax({
      type : "POST", 
      url : "http://192.168.1.130:8000/api/user/author/", 
      data : '{"first_name": "111","second_name": "222"}', 
      success: function(){
        alert('Submit Success')
      },
      dataType : 'json', 
      contentType : 'application/json',
      processData: false
    });

my api.py like this:

class AuthorResource(ModelResource):
    class Meta:
        queryset = Author.objects.all()
        resource_name ='author'
        fields = ['first_name','last_name']
        filtering = {
            'first_name': ALL,
        }
        authentication = Authentication()
        authorization = Authorization()

it returns 200 and post nothing.How can I reslove it?

4

3 に答える 3

0

これはdjango-tastypie の POST でデータを返すのだまです。

always_return_data = TrueResource メタに追加する

于 2012-06-09T16:38:49.277 に答える
0

オブジェクトが正常に作成された場合、オブジェクトの uri が応答ヘッダーの Location フィールドに表示されます。

于 2012-09-28T14:58:53.373 に答える