为django提供生产静态文件。
dj-static的Python项目详细描述
这是一个简单的django中间件实用程序,它允许您正确地 使用像gunicorn这样的wsgi服务器提供生产中的静态资产。
姜戈doesn’t recommend 其静态文件服务器的生产使用有许多原因。 然而,有一个可爱的WSGi应用程序被恰当地命名为Static。
与django不同,它适合于静态文件服务的生产使用。
用法
在settings.py:
中配置静态资产STATIC_ROOT = 'staticfiles' STATIC_URL = '/static/'
然后,更新wsgi.py文件以使用dj static:
from django.core.wsgi import get_wsgi_application from dj_static import Cling application = Cling(get_wsgi_application())