A basic sync/async static asset middleware for Django.
Designed to allow simple running of a purely admin Django instance under Daphne without having to worry about hosting admin static assets.
Install using pip
:
pip install django-sam
Add django_sam
to Django installed apps in settings.
Add django_sam.middleware.static_admin_middleware
to your MIDDLEWARE
setting, just after django.middleware.security.SecurityMiddleware
Ensure that Django is configured for static assets generation and that the STATIC_ROOT
and STATIC_URL
settings are set.
Ensure that static assets have been generated using python manage.py collectstatic
.
Serve using Daphne (or the development server while developing).
This middleware is deliberately very basic and hasn't been tested for static asset hosting beyond those generated by the Django admin. While it may well work for larger static file projects it is recommended that normal CDN-based static file hosting be used in those cases.