def handleUpload(request):
  if request.method == 'POST':
    form = UploadFileForm(request.POST, request.FILES)
    if form.is_valid():
      f = request.FILES['file']
      filename = os.path.basename(f.name)
      filepath = os.path.join('public', 'media', Config.UPLOAD_DIR)
      if not os.path.exists(filepath):
        os.makedirs(filepath, 0755)
      filepath = os.path.join(filepath, filename)
      if os.path.exists(filepath):
        return (form, 'Upload failed', 'The file \'%s\' already exists.'%(filename))
      destination = open(filepath, 'wb+')
      for chunk in f.chunks():
          destination.write(chunk)
      destination.close()
      msg = 'The file has been successfully uploaded.  Congrats!<br/><br/> \
             See for yourself:<br/> \
             <a href=\'/media/%s/%s\'>.../media/%s/%s</a>' % (Config.UPLOAD_DIR, \
             filename, Config.UPLOAD_DIR, filename)
      return (form, 'Upload successful', msg)
    return (form, 'Upload failed', 'Unable to upload the file.  Try again.')
  else:
    form = UploadFileForm()
  return (form, '', '')
Modify the query selector by applying any formatters to it.
dataset/ETHPy150Open DeanCutlet/filestack/views.py/handleUpload--crossover with--dataset/ETHPy150Open tylertreat/BigQuery-Python/bigquery/query_builder.py/_format_select