gunicorn+Django加载静态文件

问题描述

依照官方文档添加静态文件, 执行命令python managy.py runserver时运行正常, 执行命令gunicorn -k gevent mysite.wsgi时加载静态文件报错404.

解决方案

修改mysite/wsgi.py

...
from django.contrib.staticfiles.handlers import StaticFilesHandler # 添加模块
# 修改 application = get_wsgi_application()
application = StaticFilesHandler(get_wsgi_application())

Nail it! Nice and neat.

原文地址:https://www.cnblogs.com/goldenretriever/p/15627056.html