<p>I'm writing an image bank with Django, and I want to add a  button to get a hi-res version of an image (the low-res is shown in the details page).  If I put just an <code>&lt;a&gt;</code> link, the browser will open the image instead of downloading it.  Adding an HTTP header like:</p>

<pre><code>Content-Disposition: attachment; filename="beach008.jpg"
</code></pre>

<p>works, but since it's an static file, I don't want to handle the request with Django.  Currently, I'm using NGINX to serve static files, and dynamic pages are redirected via FastCGI to the Django process.  I'm thinking about using NGINX <code>add-header</code> command, but could it set the <code>filename="xx"</code> part?.  Or maybe there's some way to handle the request in Django, but make NGINX serve the content?</p>

I wrote a simple decorator, for django.views.static.serve view
Which works for me perfectly.
```
```
def serve_download(view_func):
    def _wrapped_view_func(request, *args, **kwargs):
        response = view_func(request, *args, **kwargs)
        response['Content-Type'] = 'application/octet-stream';
        import os.path
        response['Content-Disposition'] = 'attachment; filename="%s"' % os.path.basename(kwargs['path'])
        return response
    return _wrapped_view_func
```
```
Also you can play with nginx mime-types
http://wiki.codemongers.com/NginxHttpCoreModule#types
This solution didn't work for me, because I wanted to have both direct link for the file (so user can view images, for example), and download link.