Registry / devops / django-sendfile2

django-sendfile2

JSON →
library0.7.2pypypi✓ verified 81d ago

Abstraction to offload file uploads to web-server (e.g. Apache with mod_xsendfile) once Django has checked permissions etc. Current version 0.7.2, maintenance mode.

pip install django-sendfile2
INSTALL
IMPORT
SIG · DJANGO-SENDFILE2
D
django-sendfile2
devopspythonv0.7.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sendfile
from django_sendfile import sendfile
from sendfile import sendfile

Basic usage to serve a file with x-sendfile header.

from django.http import HttpResponse from sendfile import sendfile def download_view(request, filepath): # filepath is absolute path to file return sendfile(request, filepath, attachment=True, attachment_filename='report.pdf')
Debug
Known issues
gotchaImport is from sendfile, not from django-sendfile2. The package name on PyPI is django-sendfile2, but the module is sendfile.
fix
Use 'from sendfile import sendfile'
affects: all
gotchaThe filepath must be an absolute path on the filesystem. Relative paths or paths outside the allowed root will raise SuspiciousFileOperation.
fix
Ensure filepath starts with '/' and is within the SENDFILE_ROOT setting
affects: all
deprecatedThe 'sendfile' function in version 0.4.0 changed signature; 'mimetype' parameter replaced by 'content_type'. Old code using 'mimetype' may break.
fix
Use 'content_type' instead of 'mimetype'
affects: >=0.4.0
gotchaThe library does not support streaming or large files if SENDFILE_BACKEND is set to 'simple' (Django dev server). It reads the entire file into memory.
fix
Use a production backend like 'sendfile.backends.xsendfile' for Apache or 'sendfile.backends.nginx' for nginx
affects: all
Upgrade
Version history
0.7.2latest on PyPI · released Apr 6, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
14
Amazon
1
Resources
django-sendfile2 — pip install django-sendfile2 · libregistry