So I\'m building a Django progressive web app with offline support using service workers.
According to google\'s documentation, the sw.js file should be at the root
You can serve javascript as a view, not just html. Put this in your projects urls.py
url(r'^service-worker.js', cache_control(max_age=2592000)(TemplateView.as_view(
template_name="service-worker.js",
content_type='application/javascript',
)), name='service-worker.js'),
Then put your service-worker.js in your templates directory.
Bonus is that you can now also use template tags like static in your javascript file.