python - Django collectstatic no such file or directory -
in django 1.7 collectstatic throws exception me:
oserror: [errno 2] no such file or directory: '/static'
i've performed lot of collectstatic
-calls , worked fine, today have issue.
settings.py
base_dir = os.path.dirname(os.path.realpath(__file__)) installed_apps = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'fxblog', 'rest_framework', ) static_url = '/static/' static_root = os.path.join(base_dir, static_url.strip("/")) staticfiles_dirs = ( '/static/', '/upload/', )
base_dir correct, checked it. directory base_dir/static/ exists , static files there.
traceback:
traceback (most recent call last): file "../manage.py", line 10, in <module> execute_from_command_line(sys.argv) file "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 399, in execute_from_command_line utility.execute() file "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) file "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 242, in run_from_argv self.execute(*args, **options.__dict__) file "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 285, in execute output = self.handle(*args, **options) file "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 415, in handle return self.handle_noargs(**options) file "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 173, in handle_noargs collected = self.collect() file "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 103, in collect path, storage in finder.list(self.ignore_patterns): file "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/finders.py", line 106, in list path in utils.get_files(storage, ignore_patterns): file "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/utils.py", line 25, in get_files directories, files = storage.listdir(location) file "/usr/local/lib/python2.7/dist-packages/django/core/files/storage.py", line 249, in listdir entry in os.listdir(path): oserror: [errno 2] no such file or directory: '/static'
any suggestions?
files in staticfiles_dirs need have absolute path. use normpath.
staticfiles_dirs = ( normpath(join(base_dir, 'static')), normpath(join(base_dir, 'upload')), )
also set static_root like
static_root = normpath(join(base_dir, 'assets'))
and static_url
static_url = '/static/'
Comments
Post a Comment