gpt4 book ai didi

Django-admin collectstatic 是一个未知命令

转载 作者:行者123 更新时间:2023-12-05 02:09:13 25 4
gpt4 key购买 nike

尝试收集我的静态文件,因为我很快就会部署我的网站。接收:

Unknown command: 'collectstatic'

查看 django-admin 帮助后我收到此警告:

(error: Requested setting INSTALLED_APPS, but settings are not configured. 
You must either define the environment variable DJANGO_SETTINGS_MODULE or call
settings.configure() before accessing settings.).

这是我的 manage.py:

def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'xwordsite.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)

我试过运行 manage.py shell,但没有解决问题。我也不确定它是否重要,但我所有的静态文件都在项目目录中。还有静态设置:

STATIC_URL = '/static/'
STATIC_ROOT = "C:/Users/Joseph/Desktop/xwordsite/static"

最佳答案

根据 the docs :

只需编写 python manage.py collectstatic 即可。

关于Django-admin collectstatic 是一个未知命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60159761/

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