[英]The Django project that has been debugged locally is deployed to the centos7 server
将本地已经调试好的Django项目部署到centos7服务器上,发现static文件镜像和CSS之前的本地调试过程找不到问题, 如何在服务器中部署 static 文件。 我在网上搜索了很多问题,但我没有解决这个问题。 谢谢
首先确保您在项目的settings.py
中定义STATIC_ROOT
和STATIC_URL
:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
之后使用 django 管理命令(即python manage.py collectstatic
)收集您的 static 文件(注意:在您的服务器上而不是在本地计算机上使用此命令)。 Then add config of static root directory to your web server project's configs for serving static files and I don't know which web server you're using at the moment (Ex: Nginx) and finally reload your web server to update the old configs.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.