我想做这样的事情:
STATIC_ROOT = 'user@123.123.123.132:/home/static-files/'有什么简单的方法可以做到这一点吗?
发布于 2013-09-27 14:55:01
您可以使用交换矩阵收集静态文件并将其部署到远程服务器。
Django文档中有示例代码。
from fabric.api import *
from fabric.contrib import project
env.roledefs['static'] = ['user@123.123.123.132',]
# Where the static files get collected locally. Your STATIC_ROOT setting.
env.local_static_root = '/tmp/static'
# Where the static files should go remotely
env.remote_static_root = '/home/static-files'
@roles('static')
def deploy_static():
local('./manage.py collectstatic')
project.rsync_project(
remote_dir = env.remote_static_root,
local_dir = env.local_static_root,
delete = True
)然后通过运行以下命令部署静态文件:
fab deploy_statichttps://stackoverflow.com/questions/19053399
复制相似问题