我正在尝试使用 curl 进行 POST:
curl --dump-header - -H "Content-Type: application/json" -X POST --data '{"item_id": "1"}' http://www.mylocal.com:8000/api/1/bookmarks/
但是,request.POST 始终为空。
下面是我的模型资源代码:
class BookmarkResource(ModelResource):
class Meta:
queryset = Bookmark.objects.all()
resource_name = 'bookmarks'
fields = ['id', 'tags']
allowed_methods = ['get', 'post', 'delete', 'put']
always_return_data = True
authorization= Authorization()
include_resource_uri = False
def determine_format(self, request):
return "application/json"
def obj_create(self, bundle, **kwargs):
request = bundle.request
try:
payload = simplejson.loads(request.POST.keys()[0])
except:
payload = simplejson.loads(request.POST.keys())
有人知道我错过了什么吗?
提前致谢。