Django在部署web服務(wù)時(shí)公般,通常會(huì)使用Nginx來訪問靜態(tài)資源目錄/static撵枢,這時(shí)我們可以通過命令收集共用的靜態(tài)資源文件和APP目錄中的/static揖曾。
執(zhí)行命令:python manage.py collectstatic
如果報(bào)錯(cuò):django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
命令執(zhí)行成功后刺彩,會(huì)在項(xiàng)目的根路徑下生成/static目錄钓丰。