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.

posted @ 2021-11-30 23:39  Blind  阅读(193)  评论(0编辑  收藏  举报