gpt4 book ai didi

python - Bootstrap 未设置为 Django 应用程序

转载 作者:太空狗 更新时间:2023-10-29 17:58:25 24 4
gpt4 key购买 nike

Bootstrap does not be set to my Django app.In google console,Failed to load resource: the server responded with a status of 404 (Not Found) bootflat.min.css 错误发生。我在 settings.py 中写了

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DEBUG =True

STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR, "static/")

STATICFILES_DIRS = [os.path.join(BASE_DIR,'bootflat.github.io'), ]

在 PythonServer_nginx.conf 中

server {
# the port your site will be served on
listen 8000;
# the domain name it will serve for
server_name MyServerIPAdress; # substitute your machine's IP address or FQDN
charset utf-8;

# max upload size
client_max_body_size 75M; # adjust to taste

location /static {
alias /home/ubuntu/PythonServer/PythonServer/accounts/static; # your Django project's static files - amend as required
}

# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /home/ubuntu/PythonServer/uwsgi_params; # the uwsgi_params file you installed
}
}

我不知道为什么 Bootstrap 没有设置到我的 Django 应用程序。我运行命令 python manage.py collectstatic 但没有发生错误。我应该如何解决这个问题?我应该怎么写?

最佳答案

我假设该元素在本地运行良好,只有在使用 nginx 时才会出现此问题。如果是这种情况,您在 nginx 配置中为 location/static 提到的路径可能是错误的,请尝试从服务器获取静态文件夹的绝对路径并查看。

关于python - Bootstrap 未设置为 Django 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47889459/

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