Django 的管理页面缺少典型的格式/样式,我是否设置错误?
我终于让我的 django 安装工作了,但是我注意到管理页面的典型外观和感觉丢失了,而且就好像没有将样式应用于页面结构。我是否存在某种设置问题或路径问题导致无法找到样式表?它们存储在哪里?我的页面看起来像是 1994 年的。
I finally got my django install working, however I'm noticing that the typical look and feel of the admin pages are missing, and it's as if there are no styles applied to the structure of the pages. Do I have some kind of setup issue or pathing issue that's preventing the style sheets from being found? Where are they stored? My pages look like they are from 1994.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
听起来您的管理媒体未正确提供。在
settings.py
中,有一个名为ADMIN_MEDIA_PREFIX
的变量,它指定 Django 应在其中查找它们的 URL。实际的媒体文件位于“[Python 站点包的路径]/django/contrib/admin/media”中。使用manage.py runserver
时,文件会“自动”提供。然而,当使用 Apache/nginx/etc 时,您有责任确保您的服务器使文件在该 URL 上可用(使用重写规则、符号链接等)。更多信息可以在此处找到。Sounds like your admin media isn't being served correctly. In your
settings.py
, there's a variable calledADMIN_MEDIA_PREFIX
, which specifies the URL where Django should look for them. The actual media files are in "[path to your Python site-packages]/django/contrib/admin/media". When usingmanage.py runserver
, the files are served "automagically". However, when using Apache/nginx/etc it's your responsibility to make sure that your server makes the files available at that URL (using rewrite rules, symlinks, etc). More info can be found here.我已经用 apache 上的别名简单地解决了这个问题:
I've solved this issue simply with the alias on apache:
您需要提供更多信息以供正确使用以帮助您。但是,这很可能是因为没有设置您的 Web 服务器来提供静态文件,因此未加载管理 CSS。
为了解决这个问题,请管理员查看 HTML 源代码。您将 css 指向 admind css 的路径。让您的 Web 服务器在此路径上为该文件提供服务。
You need to provide more info for use to help you properly. However, this is most probably because didn't set up your Web server to serve static file, and therefor, the admin CSS is not loaded.
To solve this, got the the admin and look at the HTML source. You'll css the path to the admind css. Make your web server service this file on this path.