Django:丑陋的管理界面
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
将
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
尝试添加媒体别名。在设置 Apache 的 nginx 代理时,我遇到了同样的问题,添加媒体别名后解决了问题。
这是我的 nginx 站点配置文件中的示例:
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:
您可能设置了错误的 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.
我还没有设置任何服务静态文件。所有请求都通过 FastCgi 发送给 Django,我的 nginx 配置如下所示:
server {
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 {