Django:丑陋的管理界面

发布于 2024-09-11 19:53:38 字数 136 浏览 3 评论 0原文

我在 Debian VM 上使用 Django,django 服务器通过 nginx 加载。到目前为止,除了管理界面之外,一切都工作正常。事实上,管理站点不会加载界面的“外观和感觉”。看起来 CSS 和图像根本没有加载,有什么想法吗?

谢谢。

I'm using Django on a Debian VM, django server is loaded through nginx. Everything's working fine 'til now, except the admin interface. In fact, the admin site, doesn't load the "look and feel" of the interface. It seems that Css and images aren't loading at all, any ideas?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

安静 2024-09-18 19:53:38

ADMIN_MEDIA_PREFIX 更改为您的媒体所在的位置。如果您没有复制媒体,请从存储 django 的位置复制它,其中有一个 media 和 admin 目录。

类似的问题: Django admin 没有样式

Change ADMIN_MEDIA_PREFIX to wherever your media is. If you didn't copy the media, copy it from wherever django is stored, there's a media and admin directory.

Similar question: Django admin has no style

梦年海沫深 2024-09-18 19:53:38

尝试添加媒体别名。在设置 Apache 的 nginx 代理时,我遇到了同样的问题,添加媒体别名后解决了问题。

这是我的 nginx 站点配置文件中的示例:

location  /media/ {
   alias /opt/django-env/django_project/media/;
}

location /admin_media/ {
  alias /opt/django-env/lib/python2.6/site-packages/django/contrib/admin/media/;
}

Try adding the media aliases. I had the same problem when setting up an nginx proxy to Apache, and after adding the media aliases I solved the problem.

Here's a sample that I have in my an nginx site configuration file:

location  /media/ {
   alias /opt/django-env/django_project/media/;
}

location /admin_media/ {
  alias /opt/django-env/lib/python2.6/site-packages/django/contrib/admin/media/;
}
再浓的妆也掩不了殇 2024-09-18 19:53:38

您可能设置了错误的 ADMIN_MEDIA_PREFIX 设置,或者根本没有将服务器设置为从该 URL 提供任何内容。如果您已正确设置所有这些,请确保已将 Django 管理媒体复制(或链接)到您的项目。

You have probably set the wrong ADMIN_MEDIA_PREFIX setting or simply not set the server up to serve anything from that URL. If you have set all of that correctly, make sure you have copied (or linked) the Django admin media to your project.

自找没趣 2024-09-18 19:53:38

我还没有设置任何服务静态文件。所有请求都通过 FastCgi 发送给 Django,我的 nginx 配置如下所示:

server {

    listen   192.168.61.130:80; ## listen for ipv4
    ##listen   [::]:80 default ipv6only=on; ## listen for ipv6

    server_name  192.168.61.130;

    access_log  /var/log/nginx/localhost.access.log;
    error_log   /var/log/nginx/localhost.error.log;

    location / {
            root   /var/www/socratie;
            index  index.html index.htm;
            fastcgi_pass 127.0.0.1:8000;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            fastcgi_param REQUEST_METHOD $request_method;
            fastcgi_param QUERY_STRING $query_string;
            fastcgi_param SERVER_NAME $server_name;
            fastcgi_param SERVER_PORT $server_port;
            fastcgi_param SERVER_PROTOCOL $server_protocol;
            fastcgi_param CONTENT_TYPE $content_type;
            fastcgi_param CONTENT_LENGTH $content_length;
            fastcgi_pass_header Authorization;
            fastcgi_intercept_errors off;
    }

I haven't setted up any serving static files. All requests are served to Django via FastCgi and my nginx conf looks like this:

server {

    listen   192.168.61.130:80; ## listen for ipv4
    ##listen   [::]:80 default ipv6only=on; ## listen for ipv6

    server_name  192.168.61.130;

    access_log  /var/log/nginx/localhost.access.log;
    error_log   /var/log/nginx/localhost.error.log;

    location / {
            root   /var/www/socratie;
            index  index.html index.htm;
            fastcgi_pass 127.0.0.1:8000;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            fastcgi_param REQUEST_METHOD $request_method;
            fastcgi_param QUERY_STRING $query_string;
            fastcgi_param SERVER_NAME $server_name;
            fastcgi_param SERVER_PORT $server_port;
            fastcgi_param SERVER_PROTOCOL $server_protocol;
            fastcgi_param CONTENT_TYPE $content_type;
            fastcgi_param CONTENT_LENGTH $content_length;
            fastcgi_pass_header Authorization;
            fastcgi_intercept_errors off;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文