How to make Django serve static files with Gunicorn?

When in development mode and when you are using some other server for local development add this to your url.py

from django.contrib.staticfiles.urls import staticfiles_urlpatterns

# ... the rest of your URLconf goes here ...

urlpatterns += staticfiles_urlpatterns()

More info here

When in production you never, ever put gunicorn in front. Instead you use
a server like nginx which dispatches requests to a pool of gunicorn workers and also serves the static files.

See here

Leave a Comment