def upload_image(request): if request.method == "POST": if len(request.FILES) > 0: filename = save_file(request.FILES['picture']) width, height = get_image_size(filename) picture = Picture() picture.picture_url = filename picture.posted_on = datetime.datetime.now() picture.text = "testing hardstyle" picture.published = True picture.width = width picture.height = height picture.save() response_data = {} response_data['image_id'] = picture.pk return HttpResponse(simplejson.dumps(response_data), mimetype="application/json")