我正在尝试在pythonanywhere的bash终端中使用collectstatic
命令:
python manage.py collectstatic
但我明白了:
PermissionError:[Errno 13]权限被拒绝:'/ static'
请有人帮忙吗?我一直试图解决这个问题两天了。
这是完整的错误:
nomadpad-virtualenv)11:51~ / nomadpad(master)$ python manage.py collectstatic复制'/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/djang o / contrib /admin/static/admin/img/inline-delete.svg'Trailback(最近一次调用最后一次):文件“manage.py”,第22行,在execute_from_command_line(sys.argv)文件“/home/DMells123/.virtualenvs/ nomadpad-virtualenv / lib / python3.6 / site-packages / django /core/management/init.py“,第364行,在execute_from_command_line utility.execute()文件”/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib /python3.6/site-packages/django /core/management/init.py“,第356行,执行self.fetch_command(子命令).run_from_argv(self.argv)文件”/home/DMells123/.virtualenvs/nomadpad- virtualenv / lib / python3.6 / site-packages / django /core/management/base.py“,第283行,在run_from_argv中自执行(* args,cmd_options)文件”/home/DMells123/.virtualenvs/nomadpad-virtualenv /lib/python3.6/site-packages/django /core/management/base.py“,第330行,在执行输出= self.handle(* args,options)文件“/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py “,第199行,在句柄中收集= self.collect()文件”/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django / contrib / staticfiles / management / commands / collectstatic。 py“,第124行,收集处理程序(path,prefixed_path,storage)文件”/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django / contrib / staticfiles / management / commands / copystatic.py“,第364行,在copy_file中self.storage.save(prefixed_path,source_file)文件”/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django / core / files / storage.py“,第54行,保存返回self._save(名称,内容)文件”/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django / core / files / storage .s“,第321行,在_save os.makedirs(目录)文件中“/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/os.py”,第210行,在makedirs makedirs(head,mode,exist_ok)文件“/home/DMells123/.virtualenvs/nomadpad-virtualenv /lib/python3.6/os.py“,第210行,在makedirs makedirs(head,mode,exist_ok)文件”/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/os.py“,第220行,在makedirs中mkdir(名称,模式)PermissionError:[Errno 13]权限被拒绝:'/ static'
静态设置
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates')
STATIC_DIR = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [STATIC_DIR, ]
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_DIR = os.path.join(BASE_DIR, 'posts/media')
MEDIA_ROOT = MEDIA_DIR
MEDIA_URL = '/media/'
答案 0 :(得分:2)
我在STATIC_ROOT
中遗漏了一点,应该是posts/static
。