def send_file(request, download_key):
    if not request.session.get('download_key', False):
        url = urlresolvers.reverse('satchmo_download_process', kwargs = {'download_key': download_key})
        return HttpResponseRedirect(url)
    valid, msg, dl_product = _validate_key(request.session['download_key'])
    if not valid:
        url = urlresolvers.reverse('satchmo_download_process', kwargs = {'download_key': request.session['download_key']})
        return HttpResponseRedirect(url)

    # some temp vars
    file = dl_product.downloadable_product.file
    file_url = '/%s' % file.name # create an absolute/root url

    # poll listeners
    url_dict = {'url': file_url}
    sendfile_url_for_file.send(
        None, file=file,
        product=dl_product.downloadable_product,
        url_dict=url_dict,
    )
    # url may have changed; update it
    file_url = url_dict['url']

    # get file name from url
    file_name = os.path.basename(file_url)

    dl_product.num_attempts += 1
    dl_product.save()
    del request.session['download_key']
    response = HttpResponse()
    # For Nginx
    response['X-Accel-Redirect'] = file_url
    # For Apache and Lighttpd v1.5
    response['X-Sendfile'] = file_url
    # For Lighttpd v1.4
    response['X-LIGHTTPD-send-file'] = file_url
    response['Content-Disposition'] = "attachment; filename=%s" % file_name
    response['Content-length'] =  file.size
    contenttype, encoding = mimetypes.guess_type(file_name)
    if contenttype:
        response['Content-type'] = contenttype
    return response
After the appropriate session variable has been set, we commence the download.
dataset/ETHPy150Open dokterbob/satchmo/satchmo/apps/product/modules/downloadable/views.py/send_file