Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
Guardar archivo cargado Django Jquery Ajax

Soy bastante nuevo en Python y Django y como estoy trabajando en un gran proyecto es un poco difícil ver lo que estoy haciendo mal. Me gustaría guardar el archivo cargado en mi carpeta de repositorio.

 <form action="/action_page.php" enctype="multipart/form-data"> <label for="myfile">Select a file:</label> <input type="file" id="myfile" name="myfile" multiple="multiple" /> <br /><br /> <input id="upload_submit" type="submit" /> </form>

Este es mi archivo de vistas, realmente no entiendo cómo funciona la comunicación entre los módulos aquí.

 @csrf_exempt def get_text(self, request): rand_int = random.random() return JsonResponse({"text": "Random number: " + str(rand_int)}, status=200) @csrf_exempt def save_uploaded_file(self, request): rand_int = random.random() return JsonResponse({"text": "Random number: " + str(rand_int)}, status=200)

Mis URL se ven así

 urlpatterns = [ path("admin/", admin.site.urls), path("save_uploaded_file/", url_Handler_Wrapper.save_uploaded_file, name="save_uploaded_file"), path("get_text/", url_Handler_Wrapper.get_text, name="get_text"), path("tasks/", url_Handler_Wrapper.run_task, name="run_task"), path("", url_Handler_Wrapper.home, name="home"), ]

Y este es mi javascript

 $('#upload_submit').on('click', function() { var formData = new FormData(Document.querySelector('#myfile')) $.ajax({ url: '/save_uploaded_file/', type: 'POST', data: formData, success: function (response) { if (response) { formData.write("/") } }, error: function (error) { console.log(error) }, cache: false, contentType: false, processData: false }); return false; });
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!