Re: Upload multiple files using Ajax
I created this https://github.com/esacteksab/django-jquery-file-upload which is just jQuery-File-Upload ported to Django. It was a fork of someone elses' project that addressed my needs (support for models) On Wednesday, January 23, 2013 2:18:01 AM UTC-8, psjinx wrote: > > You can use https://github.com/blueimp/jQuery-File-Upload. > > You can use a view function similar to following. Here I have 3 models > - Project, Album and Flat > > A Project can have multiple albums. > An Album can have multiple Flats > A Flat has an ImageField, caption as TextField and a ForeignKey to Album. > > def upload_flat(request, project_slug, album_pk): > project = get_object_or_404(Project, slug=project_slug) > album = get_object_or_404(Album, pk=album_pk) > if request.method == 'GET': > flats = album.flat_set.all() > return render(request, "upload.html", {"project": project, > "album": album, "flats": flats}) > > if request.method == "POST": > form = FlatForm(request.POST, request.FILES) > if form.is_valid(): > flat = form.save(commit=False) > flat.user = request.user > flat.album = album > flat.save() > > data = { > "files": > [{ > "url": flat.image.url, > "thumbnail_url": flat.thumbnail.url, > "name": flat.image.name, > "type": "image/jpeg", > "size": flat.image.size, > "delete_url": reverse("delete_flat", args=[flat.pk]), > "delete_type": "DELETE", > "description": flat.description > }] > } > return HttpResponse(simplejson.dumps(data)) > return render(request, "upload.html", {}) > > -- > Pankaj Singh > http://about.me/psjinx > > > On Wed, Jan 23, 2013 at 1:22 AM, Mengu> wrote: > > i used jquery.form plugin back in the day. it worked great but it had > > issues with large files. > > > > check out http://malsup.com/jquery/form/progress3.html and > > http://malsup.com/jquery/form/ > > > > On Jan 22, 6:05 pm, Andre Lopes wrote: > >> Hi, > >> > >> I need to develop a form to upload multiple files. > >> > >> I was thinking in using an Ajax uploader. I have google some options > >> but there are to many and I don't know which one to choose. > >> > >> Any recommendations about this subject? > >> > >> Best Regards, > >> André. > > > > -- > > You received this message because you are subscribed to the Google > Groups "Django users" group. > > To post to this group, send email to > > django...@googlegroups.com. > > > To unsubscribe from this group, send email to > django-users...@googlegroups.com . > > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ud8ZRVWjE4AJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Upload multiple files using Ajax
You can use https://github.com/blueimp/jQuery-File-Upload. You can use a view function similar to following. Here I have 3 models - Project, Album and Flat A Project can have multiple albums. An Album can have multiple Flats A Flat has an ImageField, caption as TextField and a ForeignKey to Album. def upload_flat(request, project_slug, album_pk): project = get_object_or_404(Project, slug=project_slug) album = get_object_or_404(Album, pk=album_pk) if request.method == 'GET': flats = album.flat_set.all() return render(request, "upload.html", {"project": project, "album": album, "flats": flats}) if request.method == "POST": form = FlatForm(request.POST, request.FILES) if form.is_valid(): flat = form.save(commit=False) flat.user = request.user flat.album = album flat.save() data = { "files": [{ "url": flat.image.url, "thumbnail_url": flat.thumbnail.url, "name": flat.image.name, "type": "image/jpeg", "size": flat.image.size, "delete_url": reverse("delete_flat", args=[flat.pk]), "delete_type": "DELETE", "description": flat.description }] } return HttpResponse(simplejson.dumps(data)) return render(request, "upload.html", {}) -- Pankaj Singh http://about.me/psjinx On Wed, Jan 23, 2013 at 1:22 AM, Menguwrote: > i used jquery.form plugin back in the day. it worked great but it had > issues with large files. > > check out http://malsup.com/jquery/form/progress3.html and > http://malsup.com/jquery/form/ > > On Jan 22, 6:05 pm, Andre Lopes wrote: >> Hi, >> >> I need to develop a form to upload multiple files. >> >> I was thinking in using an Ajax uploader. I have google some options >> but there are to many and I don't know which one to choose. >> >> Any recommendations about this subject? >> >> Best Regards, >> André. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Upload multiple files using Ajax
i used jquery.form plugin back in the day. it worked great but it had issues with large files. check out http://malsup.com/jquery/form/progress3.html and http://malsup.com/jquery/form/ On Jan 22, 6:05 pm, Andre Lopeswrote: > Hi, > > I need to develop a form to upload multiple files. > > I was thinking in using an Ajax uploader. I have google some options > but there are to many and I don't know which one to choose. > > Any recommendations about this subject? > > Best Regards, > André. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Upload multiple files using Ajax
Hi, I need to develop a form to upload multiple files. I was thinking in using an Ajax uploader. I have google some options but there are to many and I don't know which one to choose. Any recommendations about this subject? Best Regards, André. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.