Custom Backend

A django-sendfile2 backend is simply a Python module that contains a callable named sendfile, for example:
def sendfile(request, filename, **kwargs):
    response = HttpResponse()
    response["X-My-Custom-Header"] = filename
    return response

Assuming the module is in your Python path and named myModule, you’d set SENDILE_BACKEND like so:

…and use django-sendfile2 in your views as you would normally.


Don’t get confused between this sendfile callable and sendfile() used in your views. The latter accepts slightly different arguments and takes care of various Content-* headers.