Reputation: 432
I am new to django and heroku. This is the error I'm getting when I deployed my git repository to heroku. Please suggest the changes that I need to change. Thank you in advance
(website) C:\Users\website\src>heroku run python manage.py collectstatic
--noinput
Running python manage.py collectstatic --noinput
attached to terminal... up, run.1690
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__
.py", line 385, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__
.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py"
, line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py"
, line 338, in execute
output = self.handle(*args, **options)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py"
, line 533, in handle
return self.handle_noargs(**options)
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 168, in handle_noargs
collected = self.collect()
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 98, in collect
for path, storage in finder.list(self.ignore_patterns):
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 111, in list
for path in utils.get_files(storage, ignore_patterns):
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/utils.py", line 27, in get_files
directories, files = storage.listdir(location)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/files/storage.py",
line 270, in listdir
for entry in os.listdir(path):
OSError: [Errno 2] No such file or directory: '/static/static'
settings.py
STATIC_URL = '/static/'
# Template location
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(BASE_DIR), "static", "templates" ),
)
if DEBUG:
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", "static-only" )
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", "media" )
STATICFILES_DIRS = (
os.path.join(os.path.dirname(BASE_DIR), "static", "static" ),
)
Upvotes: 3
Views: 4777
Reputation: 1012
If you have declared your 'STATICFILES_DIRS' variable as below,
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
ensure:
Upvotes: 2
Reputation: 11162
Currently, it seems that the error comes from the STATICFILES_DIRS var points to a directory that does not exist:
STATICFILES_DIRS = (os.path.join(os.path.dirname(BASE_DIR), "static", "static" )
Go to your Django project directory, find the static repository, and note the absolute location. Then, edit the STATICFILES_DIRS variable in settings.py sothat it points to this location.
For me (that does not imply it should be the same for you), it looks like this:
STATICFILES_DIRS = (os.path.join(BASE_DIR, '../myapp/static'),)
Upvotes: 1