grunt exec冻结,要求Django collectstati提供0状态代码

2024-09-29 23:19:37 发布

您现在位置:Python中文网/ 问答频道 /正文

在构建静态之后,我尝试让grunt exec执行djangocollectstatic命令。所以,在我看来Gruntfile.js文件我有:

grunt.initConfig({
    ...
    exec: {
        collectstatic: {
            cwd: '../../',
            cmd: 'python manage.py collectstatic --clear'
        }
    }
    ...
}

当我尝试用grunt exec:collectstatic --verbose执行此命令时,它不会诅咒,但会冻结以下输出:

Running "exec:collectstatic" (exec) task
Verifying property exec.collectstatic exists in config...OK
File: [no files]

python manage.py collectstatic --clear
Expecting exit code 0

看起来好像它没有从django接收退出代码。我检查了一下,如果django返回正确的状态码,并且它似乎是这样做的:

$ python manage.py collectstatic --clear
$ echo $?
0

怎么了?你知道吗


Tags: 文件djangopy命令managejs静态exec
1条回答
网友
1楼 · 发布于 2024-09-29 23:19:37

默认情况下,django的collectstatic命令需要用户输入(确认确实应该收集静态文件),但grunt无法将用户的输入传递到collectstatic命令中。这将导致冻结,因为collectstatic期望输入中有内容,而grunt没有提供任何内容。你知道吗

可以通过在collectstatic命令中添加 noinput参数来更改它,因此整个命令如下所示:

python manage.py collectstatic  clear  noinput

这会解决你的问题。你知道吗

相关问题 更多 >

    热门问题