处理由jquery fileupload

时间:2016-10-10 12:37:24

标签: jquery python django jquery-file-upload

我已经按照jquery fileupload的教程编写了我编写的代码

$('#image_file').fileupload({
    dataType: 'json',
    type: 'post',
    url: '/whats-on/upload-event/?v='+event_id,
    contentType: "application/json; charset=utf-8",
    done: function (e, data) {
        console.log('done');
    }
});

它返回错误ValueError: No JSON object could be decoded

这里是尝试

时失败的python函数
@csrf_exempt
def create_event(request):
    context = RequestContext(request)
    response_data = {}
    response_data['status'] = False
    if request.FILES:
        file = request.FILES[u'files']
        response_data['status'] = True
    elif request.method == 'POST':
        data = json.loads(request.body)

它没有通过request.FILES并在达到data = json.loads(request.body)时失败

0 个答案:

没有答案