I want to run my django project under gunicorn on localhost. I installed and integrated gunicorn. When I run:
python manage.py run_gunicorn
I've used this for my development environment (which uses gunicorn):
from django.conf import settings
from django.contrib.staticfiles.handlers import StaticFilesHandler
from django.core.wsgi import get_wsgi_application
if settings.DEBUG:
application = StaticFilesHandler(get_wsgi_application())
else:
application = get_wsgi_application()
And then run gunicorn myapp.wsgi. This works similar to @rantanplan's answer, however, it does not run any middleware when running static files.