Date Modified Tags django / python

From time to time, I run into a problem that only occurs in a production-like Django setup (DEBUG off, running under gunicorn, static asset compression in play, and so on).

Debugging such issues on a staging system can be time-consuming. Sometimes, there is no alternative. But often, it's easier to debug locally with a pseudo-production setup.

In one shell:

./ collectstatic --noinput
cd static_root
python -m SimpleHTTPServer 8001

In another shell:

cd media_root
python -m SimpleHTTPServer 8002

Third shell:

DEBUG=False STATIC_URL='http://localhost:8001/' MEDIA_URL='http://localhost:8002/' gunicorn myproject.wsgi

This assumes you read these Django settings from environment variables (you probably should), and that you're using gunicorn and have it installed into your virtualenv.