Reputation: 2445
I'd like to do something like this:
STATIC_ROOT = '[email protected]:/home/static-files/'
Is there an easy way to achieve this?
Upvotes: 1
Views: 556
Reputation: 1666
You could use Fabric to collect and deploy the static files to a remote server.
There's sample code in the Django documentation.
from fabric.api import *
from fabric.contrib import project
env.roledefs['static'] = ['[email protected]',]
# 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
)
You would then deploy the static files by running:
fab deploy_static
Upvotes: 4