Steven's Blog

A Dream Land of Peace!

Gunicorn中css文件没有起作用的问题解决

I find that my bootstap files not working well while I am using gunicorn to start the app.

1
gunicorn --env DJANGO_SETTINGS_MODULE=myapp.settings myapp_management.wsgi --timeout 300 --workers=2 --pid gunicorn.pid -b 0:10000 --access-logfile=log/access_charts.log --error-logfile=log/error_charts.log --access-logformat '"%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s" %(D)s %(p)s'

I find a solution for this:

1
http://stackoverflow.com/questions/12800862/django-static-files-under-gunicorn

To summarize it here, add the following contents to the urls.py file.

1
2
3
4
from django.contrib.staticfiles.urls import staticfiles_urlpatterns


urlpatterns += staticfiles_urlpatterns()