{"id":23605,"library":"django-sri","title":"django-sri","description":"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.","status":"active","version":"0.8.0","language":"python","source_language":"en","source_url":"https://github.com/RealOrangeOne/django-sri","tags":["django","sri","subresource-integrity","security","static-files"],"install":[{"cmd":"pip install django-sri","lang":"bash","label":"Install"}],"dependencies":[{"reason":"Required. Django project.","package":"Django","optional":false}],"imports":[{"note":"Common mistake: using django_sri instead of sri","wrong":"from django_sri.storage import SRIStaticFilesStorage","symbol":"SRIStaticFilesStorage","correct":"from sri.storage import SRIStaticFilesStorage"},{"note":"","wrong":null,"symbol":"SriTag","correct":"from sri.templatetags.sri import SriTag"}],"quickstart":{"code":"# settings.py\nINSTALLED_APPS = [\n    ...,\n    'sri',\n]\nSTATICFILES_STORAGE = 'sri.storage.SRIStaticFilesStorage'\n\n# In template\n{% load sri %}\n<script src=\"{% static 'js/app.js' %}\" {{ 'js/app.js'|sri }}></script>","lang":"python","description":"Add sri to INSTALLED_APPS, set storage backend, use sri filter in templates"},"warnings":[{"fix":"Change all imports from django_sri to sri.","message":"In version 0.8.0, the library module was renamed from django_sri to sri. Imports using 'from django_sri...' will break.","severity":"breaking","affected_versions":">=0.8.0"},{"fix":"Run collectstatic after every static file change.","message":"The SRI hash is computed at deploy time (collectstatic) on the static file content. If files change after collectstatic, the hash will mismatch.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace SRI_ALGORITHM = 'sha384' with SRI_ALGORITHMS = ['sha384'].","message":"The old setting 'SRI_ALGORITHM' is deprecated in favor of 'SRI_ALGORITHMS' (list) in version 0.8.0.","severity":"deprecated","affected_versions":">=0.8.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Change all imports to use 'sri' (e.g., from sri.storage import ...).","cause":"Library was renamed from django_sri to sri in version 0.8.0.","error":"ModuleNotFoundError: No module named 'django_sri'"},{"fix":"In templates, use {% load sri %} before using the sri filter. Do not import sri.templatetags directly.","cause":"Typical if you try to import sri.templatetags before app is ready or without loading the templatetag module.","error":"AttributeError: module 'sri' has no attribute 'templatetags'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}