Django管理员样式已损坏 [英] Django Admin Styling corrupted

查看:106
本文介绍了Django管理员样式已损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近对django站点进行了一些更改,其中一个很大的变化是从Django 2.2升级到3.1。现在我的管理网站样式全部搞砸了。我不知道出了什么问题或如何解决。任何指针将不胜感激!
查看更新后的图像。...
admin的主页看起来不错,但是当我单击其中一个模型进行查看时,格式肯定不正确。
另外,我在网站上的一些图像(不是全部)都说找不到404 ...

I recently made some changes to my django site, one big one being upgrading from Django 2.2 to 3.1. Now my admin site styling is all messed up. I can't figure out what went wrong or how to fix. Any pointers would be appreciated! See image of what it looks like after update.... The main home page for admin looks fine, but when I click on one of the models to view, the formatted is definitely not correct. Also, some not all, of my images on the site are saying 404 not found...

推荐答案

我遇到了同样的问题,首先我想这是一个缓存问题,但不是。
我检查了页面源代码,发现一个css文件正在应用到该页面,该文件甚至不在我的驱动器上。

I was facing the same problem, First I thought it was a Cache issue but it wasn't. I checked the page source and found a css file being applied to the page which wasn't even present on my drive.

在我的情况下,该文件是:
static / admin / css / nav_sidebar.css

In my case the file was: static/admin/css/nav_sidebar.css

所以我在 static / admin / css 中创建了名为的新文件nav_sidebar.css ,然后
复制粘贴从页面源中获取的代码,然后
添加 display:none;;在#nav-sidebar部分(第34行)和[dir = rtl]#nav-sidebar部分(在我的情况下为第45行)。

So I created new file in static/admin/css named nav_sidebar.css, then copy pasted the code which I got from page source and added "display:none;" in the #nav-sidebar section(line:34) and [dir="rtl"] #nav-sidebar section(line:45 in my case).

使用Google Chrome浏览器的检查工具在此处获得原始代码。
在哪里找到代码

You can find the Original code here by using Google Chrome's inspect tool. Where to find the code

这篇关于Django管理员样式已损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆