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

标签 python css django bootstrap-4

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/

相关文章:

python - 列切片和行切片之间哪个是哪个?

python - 使用请求通过http协议(protocol)将设置发送到clickhouse

python - 在 Python 中计算重复整数

css - 导航栏下拉菜单在使用媒体查询的移动设备和小型设备上显示问题

asp.net - 使用 SquishIt 在母版页和 View 页面中组合 CSS 和 JS

jquery - 放大和重新定位光滑 slider 的箭头

django - ssl 与 django Gunicorn 和 nginx

jquery - 为什么即使 $.getJSON 运行正常,警报也没有运行? (回调未执行,即使请求使用 getJSON 工作正常)

python - WSL 上的 Virtualenv 创建的文件与 PowerShell 上的 Virtualenv 不同

python - 在指定 update_fields 时使用 pre_save