Django Admin Styling corrupted

Viewed 2048

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... enter image description here

enter image description here

6 Answers

It looks like your browser is caching the CSS / JS from the old version, you can clear your cache and reload. In chrome use ctrl + shift + r to reload.

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.

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

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).

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

I had the same issue after bumping django from v3.0 to v3.1. I run python manage.py collectstatic to update css which solved my issue

I think the other answers here are necessary, but I'll add one more: You might have to bust caches in your server itself. In our example, nginx was configured to provide really long caches to our static files, so we just had to reset it to make changes come through.

I was experiencing the same styling as the OP's screenshots.

I had upgraded incrementally from 2.2 -> 3.0 -> 3.1 -> 3.2. I only experienced the styling issues in 3.2

The issue was that there were legacy admin styles committed to the repo in the static folder. To resolve, all I did was delete the committed admin styles, and Django then appeared to use its own styling

I was upgrading from 3.0 to 3.2 and I tried a couple of the answers here without luck. At the end, the following procedure solved it for me:

  1. manually delete the content of the directory STATIC_ROOT (see in settings.py what you named the folder)
  2. run the command python manage.py collectstatic This will repopulate the directory with the newst files
  3. hard refresh your page (ctrl + F5)
Related