@login_required
@require_POST
@xframe_options_sameorigin
def up_image_async(request, model_name, object_pk):
 if (model_name not in ALLOWED_MODELS):
  message = _('Model not allowed.')
  return HttpResponseBadRequest(json.dumps({'status': 'error', 'message': message}))
 m = get_model(*model_name.split('.'))
 try:
  obj = m.objects.get(pk=object_pk)
 except ObjectDoesNotExist:
  message = _('Object does not exist.')
  return HttpResponseNotFound(json.dumps({'status': 'error', 'message': message}))
 try:
  file_info = upload_imageattachment(request, obj)
 except FileTooLargeError as e:
  return HttpResponseBadRequest(json.dumps({'status': 'error', 'message': e.args[0]}))
 if (isinstance(file_info, dict) and ('thumbnail_url' in file_info)):
  return HttpResponse(json.dumps({'status': 'success', 'file': file_info}))
 message = _('Invalid or no image received.')
 return HttpResponseBadRequest(json.dumps({'status': 'error', 'message': message, 'errors': file_info}))

@ login_required @ require_POST @ xframe_options_sameorigin def up_image_async ( request , model_name , object_pk ) : if ( model_name not in ALLOWED_MODELS ) : message = _ ( 'Model not allowed.' ) return HttpResponseBadRequest ( json . dumps ( { 'status' : 'error' , 'message' : message } ) ) m = get_model ( * model_name . split ( '.' ) ) try : obj = m . objects . get ( pk = object_pk ) except ObjectDoesNotExist : message = _ ( 'Object does not exist.' ) return HttpResponseNotFound ( json . dumps ( { 'status' : 'error' , 'message' : message } ) ) try : file_info = upload_imageattachment ( request , obj ) except FileTooLargeError as e : return HttpResponseBadRequest ( json . dumps ( { 'status' : 'error' , 'message' : e . args [ 0 ] } ) ) if ( isinstance ( file_info , dict ) and ( 'thumbnail_url' in file_info ) ) : return HttpResponse ( json . dumps ( { 'status' : 'success' , 'file' : file_info } ) ) message = _ ( 'Invalid or no image received.' ) return HttpResponseBadRequest ( json . dumps ( { 'status' : 'error' , 'message' : message , 'errors' : file_info } ) )
upload all images in request .