I've been trying to get dj-static to work on my site but for some reason it doesn't seem to work with gunicorn. This can't be (that's the whole point of dj-static!) and I was sure it was PEBCAK, so I created a brand new hellodjango app following the instructions here to be sure it wasn't something in my code.
Activate the virtualenv: $ source venv/bin/activate
Run collectstatic (you may have to do $ mkdir staticfiles first): $ foreman run python manage.py collectstatic --noinput
Now, run foreman run python manage.py runserver and visit http://127.0.0.1:8000/static/test.txt and see SUCCESS. Looking good so far!
Kill that and run gunicorn foreman run gunicorn hellodjango.wsgi and visit http://127.0.0.1:8000/static/test.txt and see a 'Page not found (404)' error. If you visit http://127.0.0.1:8000 instead you'll see that gunicorn does work, just not for static content.
How can this be? What am I doing wrong?
Thanks!
Also, one uber-weird note: if I set DEBUG and TEMPLATE_DEBUG to False. Then I get a 404 page using both runserver and gunicorn. Perhaps this is the same thing happening in issue #11?
I've been trying to get
dj-static
to work on my site but for some reason it doesn't seem to work withgunicorn
. This can't be (that's the whole point ofdj-static
!) and I was sure it was PEBCAK, so I created a brand newhellodjango
app following the instructions here to be sure it wasn't something in my code.Steps to reproduce:
$ source venv/bin/activate
$ mkdir staticfiles
first):$ foreman run python manage.py collectstatic --noinput
Now, run
foreman run python manage.py runserver
and visit http://127.0.0.1:8000/static/test.txt and seeSUCCESS
. Looking good so far! Kill that and run gunicornforeman run gunicorn hellodjango.wsgi
and visit http://127.0.0.1:8000/static/test.txt and see a 'Page not found (404)' error. If you visit http://127.0.0.1:8000 instead you'll see that gunicorn does work, just not for static content.How can this be? What am I doing wrong?
Thanks!
Also, one uber-weird note: if I set
DEBUG
andTEMPLATE_DEBUG
toFalse
. Then I get a 404 page using bothrunserver
andgunicorn
. Perhaps this is the same thing happening in issue #11?