Sometimes, we want to make Python Django serve static files with Gunicorn.
In this article, we’ll look at how to make Python Django serve static files with Gunicorn.
How to make Python Django serve static files with Gunicorn?
To make Python Django serve static files with Gunicorn, we append the static file routes to urlpatterns
.
For instance, we write
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
# ...
urlpatterns += staticfiles_urlpatterns()
to append the route list returned from staticfiles_urlpatterns
to urlpatterns
.
Conclusion
To make Python Django serve static files with Gunicorn, we append the static file routes to urlpatterns
.