2

When I'm trying to deploy a Django app to Heroku, encounter the identical problem as python - Collectstatic error while deploying Django app to Heroku - Stack Overflow
it starts to build, download and installs everything, but that's what I get when it comes to collecting static files:

$ git push heroku master
Counting objects: 5375, done.
Total 5375 (delta 1092), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Python app detected
remote: -----> Installing requirements with pip
remote: 
...
remote: 
remote:  !     Error while running '$ python manage.py collectstatic --noinput'.
remote:        See traceback above for details.
remote: 
remote:        You may need to update application code to resolve this error.
remote:        Or, you can disable collectstatic for this application:
remote: 
remote:           $ heroku config:set DISABLE_COLLECTSTATIC=1
remote: 
remote:        https://devcenter.heroku.com/articles/django-assets
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed
remote: Verifying deploy....
remote: 
remote: !   Push rejected to fierce-cove-94300.
remote: 
To https://git.heroku.com/fierce-cove-94300.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/fierce-cove-94300.git'

I tried all its answers, but not helps. Additional I tried Django and Static Assets | Heroku Dev Center to configure the setting and install whitenoise and commit changes.

The problem is not solved.

AbstProcDo
  • 19,953
  • 19
  • 81
  • 138

1 Answers1

3

Disable auto collectstatic:

heroku config:set DISABLE_COLLECTSTATIC=1

Then push your project to heroku. After the deploy is done, manually collectstatic as below:

heroku run python manage.py collectstatic

If you still get errors, your static files config is probably the reason. Try making it simple, remove whitenoise and use a s3 bucket for example.

Zilong Li
  • 889
  • 10
  • 23