For other to use, the final version for downloading the file is bellow. ReferenceFile is my model.
import mimetypes from django.core.servers.basehttp import FileWrapper from django.http import HttpResponse def download(request, id): file_to_download = get_object_or_404(ReferenceFile, pk=id) if file_to_download.filename_orig is not None: filename = '%s/%s' % (MEDIA_ROOT,file_to_download.file.path) wrapper = FileWrapper(open(filename)) content_type = mimetypes.guess_type(filename)[0] response = HttpResponse(wrapper,content_type=content_type) response['Content-Length'] = os.path.getsize(filename) response['Content-Disposition'] = "attachment; filename=%s" % file_to_download.filename_orig return response [...] On 11 feb., 16:15, Tom Evans <tevans...@googlemail.com> wrote: > On Fri, Feb 11, 2011 at 2:05 PM, Gabriel - Iulian Dumbrava > > <gabriel.dumbr...@gmail.com> wrote: > > I found a solution on the second part, sending the file back to the > > user with the original filename here: > >http://stackoverflow.com/questions/1156246/having-django-serve-downlo... > > > I would still need some help on the first part. > > > Thanks, > > Gabriel > > http://docs.djangoproject.com/en/1.2/ref/models/fields/#django.db.mod... > > """ > This may also be a callable, such as a function, which will be called > to obtain the upload path, including the filename. This callable must > be able to accept two arguments, and return a Unix-style path (with > forward slashes) to be passed along to the storage system. The two > arguments that will be passed areā¦ > """ > > Cheers > > Tom -- 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.