找不到pythonanywhere中的css静态文件

问题描述 投票:1回答:2

我明白这个话题没有提出一次,我重读并尝试了所有的选项,但由于某种原因,错误不会消失,风格也没有连接到这里的图像描述

connect static

path directory

error in load site

path in templates

python django pythonanywhere static-files web-publishing
2个回答
2
投票

在您自己的本地系统上,django dev服务器将提供静态文件。在像PythonAnywhere这样的生产环境中,您需要在settings.py中设置STATIC_ROOT,例如:/home/yourusername/myproject/static

然后运行python manage.py collectstatic,它将从您的应用程序文件夹中收集静态文件并将它们放在那里


0
投票

在您的模板代码中删除以下空格:

 (% static    '  css/style.css' %)
               |
               |
               |
               |
             #this one
© www.soinside.com 2019 - 2024. All rights reserved.