首页 > 解决方案 > 找不到管理员中 nginx ubuntu 服务器上的 Django 静态文件

问题描述

我已经在带有 nginx 网络服务器的 ubuntu 服务器上设置了我的 django 项目。在我的 django settings.py 文件中我设置:

STATIC_URL = '/static/'

STATIC_ROOT = '/static/images/'

STATICFILES_DIRS = [
    '/var/www/core/frontend/static',
    '/.venv/lib/python3.6/site-packages/django/contrib/admin/static',
]

嗯,在我的 nginx.conf 文件中我写:

server {
    listen  80 default_server;
    listen  [::]:80 default_server;
  }

 # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location /static/ {
    alias /var/www/core/frontend/static/;
}       

    location / {
            proxy_pass http://127.0.0.1:8000;
        }

但是当我打开我的项目的管理部分时,我收到很多关于未找到 css 和 js 的 404 错误。

我必须在哪里实现我的代码才能正确管理静态管理文件?

非常感谢提前

标签: djangopython-3.xnginxubuntu-server

解决方案


推荐阅读