Search code examples
javascriptpythondjangogruntjsgrunt-exec

grunt exec freezes, expecting 0 status code from django collectstatic


I'm tring to make grunt exec perform django collectstatic command after building the statics. So, in my Gruntfile.js I have:

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

When I try to execute this command with grunt exec:collectstatic --verbose, it doesn't curse but freezes with the following output:

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

Looks as if it weren't receiving exit code from django. I checked, if django returns correct status code, and it seems to do so:

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

What's wrong?


Solution

  • By default, django's collectstatic command requires user input (confirmation that static files really should be collected), but grunt has no way to pass that input from user into collectstatic command. That will cause freeze because collectstatic is expecting something on input but grunt is not providing anything.

    It can be changed by adding --noinput parameter into collectstatic command, so whole command will look like this:

    python manage.py collectstatic --clear --noinput
    

    And that will solve your problem.