Sto cercando di fare un post con ricciolo:Django & TastyPie: request.POST è vuoto
curl --dump-header - -H "Content-Type: application/json" -X POST --data '{"item_id": "1"}' http://www.mylocal.com:8000/api/1/bookmarks/
Tuttavia, request.POST è sempre vuoto.
Qui di seguito è il mio codice 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())
Chiunque sa che cosa mi manca?
Grazie in anticipo.
Vedere anche http://stackoverflow.com/questions/1208067/wheres-my-json-data-in-my-incoming-django-request. – Seth
@dannyroa Che cosa differenzia "dati di modulo" e "dati non di forma"? – rrauenza
... Guardando il sorgente di Django, sembra che sia definito in '_load_post_and_files()' e dipende da 'CONTENT_TYPE' -' multipart/form-data' e 'application/x-www-form-urlencoded' – rrauenza