Registry / web-framework / django-sri

django-sri

JSON →
library0.8.0pypypi✓ verified 81d ago

Subresource Integrity (SRI) for Django. Generates integrity hashes for static files in templates. Current version: 0.8.0. Release cadence: infrequent, last release Oct 2024.

pip install django-sri
INSTALL
IMPORT
SIG · DJANGO-SRI
D
django-sri
web-frameworkpythonv0.8.0
Install
3.4s avg
Import
Disk
65MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.8.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 66.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.4s · import 0.000s · 67MB
65MB installed
● package 65MB
Code
Verified usage

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

calculate_integrity
from sri import calculate_integrity
from sri.storage import SRIStaticFilesStorage
Algorithm
from sri import Algorithm
hashers
from sri import hashers

Add sri to INSTALLED_APPS, set storage backend, use sri filter in templates

# settings.py INSTALLED_APPS = [ ..., 'sri', ] STATICFILES_STORAGE = 'sri.storage.SRIStaticFilesStorage' # In template {% load sri %} <script src="{% static 'js/app.js' %}" {{ 'js/app.js'|sri }}></script>
Debug
Known issues
breakingIn version 0.8.0, the library module was renamed from django_sri to sri. Imports using 'from django_sri...' will break.
fix
Change all imports from django_sri to sri.
affects: >=0.8.0
gotchaThe SRI hash is computed at deploy time (collectstatic) on the static file content. If files change after collectstatic, the hash will mismatch.
fix
Run collectstatic after every static file change.
affects: all
deprecatedThe old setting 'SRI_ALGORITHM' is deprecated in favor of 'SRI_ALGORITHMS' (list) in version 0.8.0.
fix
Replace SRI_ALGORITHM = 'sha384' with SRI_ALGORITHMS = ['sha384'].
affects: >=0.8.0
Upgrade
Version history
0.8.0latest on PyPI · released Jan 21, 2025
Audit
Dependencies
DjangorequiredRequired. Django project.
Agent activity
27 hits · last 30 days
node
24
Amazon
1
OpenAI (training)
1
Resources
django-sri — pip install django-sri · libregistry