def upload_image request if request method POST form ImageUploadForm r

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
def upload_image(request):
if request.method == 'POST':
form = ImageUploadForm(request.POST, request.FILES)
if form.is_valid():
path1, path2 = save_resize_picture(request.FILES['picture'])
output = simplejson.dumps({'big':path1, 'small':path2, 'description':request.POST['description']})
print output
return HttpResponse(output, mimetype='text/json' )
else:
form = ImageUploadForm()
return 'test_image.html', {'form':form}