gpt4 book ai didi

python - Collectstatic - 权限被拒绝,pythonanywhere bash 终端

转载 作者:太空宇宙 更新时间:2023-11-03 11:17:39 25 4
gpt4 key购买 nike

我正在尝试在 pythonanywhere 的 bash 终端中使用 collectstatic 命令:

python manage.py collectstatic

但是我得到:

PermissionError: [Errno 13] Permission denied: '/static'

请问有人能帮忙吗?这两天我一直在尝试解决这个问题。

这是完整的错误:

nomadpad-virtualenv) 11:51 ~/nomadpad (master)$ python manage.py collectstatic Copying '/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/djang o/contrib/admin/static/admin/img/inline-delete.svg' Traceback (most recent call last): File "manage.py", line 22, in execute_from_command_line(sys.argv) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /core/management/init.py", line 364, in execute_from_command_line utility.execute() File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /core/management/init.py", line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /core/management/base.py", line 283, in run_from_argv self.execute(*args, cmd_options) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /core/management/base.py", line 330, in execute output = self.handle(*args, options) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /contrib/staticfiles/management/commands/collectstatic.py", line 199, in handle collected = self.collect() File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /contrib/staticfiles/management/commands/collectstatic.py", line 124, in collect handler(path, prefixed_path, storage) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /contrib/staticfiles/management/commands/collectstatic.py", line 364, in copy_file self.storage.save(prefixed_path, source_file) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /core/files/storage.py", line 54, in save return self._save(name, content) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/site-packages/django /core/files/storage.py", line 321, in _save os.makedirs(directory) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/os.py", line 210, in makedirs makedirs(head, mode, exist_ok) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/os.py", line 210, in makedirs makedirs(head, mode, exist_ok) File "/home/DMells123/.virtualenvs/nomadpad-virtualenv/lib/python3.6/os.py", line 220, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: '/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/'

最佳答案

我在 STATIC_ROOT 中遗漏了一点,它应该是 posts/static

关于python - Collectstatic - 权限被拒绝,pythonanywhere bash 终端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48841074/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com