です:ジャンゴ&TastyPie:request.POSTは、私はカールを使用して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は常に空です。以下は
は私ModelResourceコードです:
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())
誰もが私が欠けている知っていますか?
ありがとうございます。
http://stackoverflow.com/questions/1208067/wheres-my-json-data-in-my-incoming-django-requestも参照してください。 – Seth
@dannyroa "フォームデータ"と "非フォームデータ"は何を区別していますか? – rrauenza
... Djangoソースを見ると、 '_load_post_and_files()'で定義され、 'CONTENT_TYPE' - ' multipart/form-data'と 'application/x-www-form-urlencoded' – rrauenza