Django推送到Heroku:"未知命令:'压缩'"?

时间:2016-06-10 02:55:04

标签: django bash heroku django-compressor wagtail

我试图将新的Django / Wagtail应用程序部署到Heroku,但遇到了麻烦。

我跟随this tutorial,直到最后一部分"在Heroku"上提供静态资产。但是,当我使用git push heroku master将应用程序推送到Heroku时,它会因此错误而失败:

...
remote:        182 static files copied to '/app/static', 182 post-processed.
remote: 
remote: -----> Running run_compress
remote: -----> Compressing static files
remote:        Unknown command: 'compress'
remote:        Type 'manage.py help' for usage.
remote: 
remote:  !     Push rejected, failed to compile Python app
remote: 
remote: Verifying deploy....
remote: 
remote: !   Push rejected to myapp.
remote: 
To https://git.heroku.com/myapp.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/myapp.git'
$

据推测Heroku在使用Django Compressor时遇到了问题,虽然教程没有指定它的安装,所以我不确定。本教程指定安装名为Heroku Django Cookbook的东西,它在run_compress文件中指定bash,如下所示:

#!/usr/bin/env bash
set -eo pipefail

indent() {
    RE="s/^/       /"
    [ $(uname) == "Darwin" ] && sed -l "$RE" || sed -u "$RE"
}

MANAGE_FILE=$(find . -maxdepth 3 -type f -name 'manage.py' | head -1)
MANAGE_FILE=${MANAGE_FILE:2}

echo "-----> Compressing static files"
python $MANAGE_FILE compress 2>&1 | indent

echo

似乎manage.py compress似乎无法正常工作。或者它可能是Whitenoise的东西,因为那是教程失败的部分。似乎安装正确。以下是我settings.py的相关行:

...
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

COMPRESS_OFFLINE = True
COMPRESS_CSS_FILTERS = [
    'compressor.filters.css_default.CssAbsoluteFilter',
    'compressor.filters.cssmin.CSSMinFilter',
]
COMPRESS_CSS_HASHING_METHOD = 'content'
...

最后,这是我的requirements.txt

beautifulsoup4==4.4.1
dj-database-url==0.4.1
dj-static==0.0.6
Django==1.9.6
django-appconf==1.0.2
django-compressor==2.0
django-modelcluster==1.1
django-taggit==0.18.3
django-toolbelt==0.0.1
django-treebeard==4.0.1
djangorestframework==3.3.3
gunicorn==19.6.0
html5lib==0.9999999
Pillow==3.2.0
psycopg2==2.6.1
python-dateutil==1.5
pytz==2016.4
rcssmin==1.0.6
requests==2.10.0
rjsmin==1.0.12
six==1.10.0
static3==0.7.0
Unidecode==0.4.19
wagtail==1.4.5
whitenoise==3.2
Willow==0.3.1

有什么想法吗?欢迎所有领导。谢谢!

1 个答案:

答案 0 :(得分:2)

您似乎未将compressor添加到INSTALLED_APPS

另外值得一提的是,自版本1.4以来Wagtail没有longer depends on django_compressor,所以如果你不需要django_compressor的功能,你可以从项目中删除它。