When doing 'git push heroku master' (from a Django app), the push gets rejected. I've included the traceback below. I can disable the collectstatic but then all the static files are missing from the webpage.
When I run python manage.py collectstatic --noinput
on my localserver it does not give any errors. I've spent the past two days on this, not sure what I'm doing wrong. I've included my .settings
below for the staticfiles. I am using whitenoise which works perfectly fine on my localhost.
I think it has to do with a relative path that is not found. But that can't be it because there are no errors on my local server?
remote: $ python manage.py collectstatic --noinput
remote: Traceback (most recent call last):
remote: File "manage.py", line 10, in <module>
remote: execute_from_command_line(sys.argv)
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
remote: utility.execute()
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
remote: self.fetch_command(subcommand).run_from_argv(self.argv)
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
remote: self.execute(*args, **cmd_options)
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
remote: output = self.handle(*args, **options)
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 176, in handle
remote: collected = self.collect()
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 98, in collect
remote: for path, storage in finder.list(self.ignore_patterns):
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 112, in list
remote: for path in utils.get_files(storage, ignore_patterns):
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/utils.py", line 28, in get_files
remote: directories, files = storage.listdir(location)
remote: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/files/storage.py", line 299, in listdir
remote: for entry in os.listdir(path):
remote: OSError: [Errno 2] No such file or directory: '/tmp/MakeCalls/Static'
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
Staticfiles:
STATICFILES_DIRS = ([
os.path.join(os.path.dirname(BASE_DIR), 'MakeCalls', 'Static'),
])
STATIC_URL = '/Static/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'MakeCalls', 'MakeCalls', 'Static')
MEDIA_ROOT = os.path.join(BASE_DIR, 'static', 'media')
MEDIA_URL = os.path.join(BASE_DIR, 'media/')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
So I managed to fix this myself. The problem was that all my static files were organized in root/Static
and served with STATICFILES_DIRS
. However, for some reason, Heroku can't read this. So I put all static files in root/app/static
and deleted the STATICFILES_DIRS
in settings and it all worked!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With