我正在使用 Django 1.3、Ubuntu 11.10、gunicorn 和 Nginx 运行一个小型测试项目,所有内容都在 virtualenv 中,现在我正在运行collectstatic 将静态文件放入 Nginx 提供服务的目录中。
为了简单起见,假设我的静态目录类似于 /home/user/static,我的项目位于 /home/user/project
当我转到 /home/user/project 时,我运行:
python manage.py collectstatic --noinput
它可以正确地从我安装的所有应用程序中复制静态文件。不幸的是,这也从 Django 的管理员复制了文件,我想跳过那个。
我检查了 collecstatic 的文档,发现有一个 -i (--ignore) 参数采用 glob 样式参数,因此我尝试了该命令的不同变体,因为我不确定忽略模式是否引用我的 /home /user/static 或原始应用程序目录。
这里有一些不起作用的例子:
python manage.py collectstatic --noinput -i /home/user/static/admin
python manage.py collectstatic --noinput -i /home/user/static/admin/*
python manage.py collectstatic --noinput -i /home/user/static/a*
python manage.py collectstatic --noinput -i /home/alexis/.virtualenvs/django13/*
python manage.py collectstatic --noinput -i /home/user/.virtualenvs/django13/lib/python2.7/site-packages/django/contrib/admin*
我发现如果我创建从 /home/user/static/admin 到 /home/user/.virtualenvs/django13/lib/python2.7/site-packages/django/contrib/admin/media 的符号链接,collectstatic 会注意到并且再次跳过复制这些文件,但无论如何,我想让 --ignore 选项正常工作。
我缺少什么?
谢谢您的帮助!
不要写目录的完整路径。例如用法:
python manage.py collectstatic --noinput -i admin
此命令不会将 admin/ 目录复制到 STATIC_ROOT 路径。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)