Reinstalling/updating Django doesn't update the admin page CSS


I upgraded my Django version from 4.1.7 to 4.2.1 on a remote deployment, and it seems that the CSS (for the admin page in particular) from the old installation persists despite running collectstatic after installing the new Django version. What are my options to fix this? My deployment is at this time not small, so I’m hoping there’s an easier way than creating a new project and moving all of it over.

For clarity, the server is indeed serving statics and I’ve verified this in the browser’s network/console with HTTP 200 for all the .css/.js files, and I’ve force-refreshed of course. I’m using the drf-spectacular package and the swagger endpoint loads all CSS just fine, so I’m speculating that my broken admin page is due to not-4.2 CSS files.


Upon further research and inspection – the CSS files in my application directory are indeed updated, but whenever I run collectstatic the files that end up in STATICROOT aren’t the same ones that are in my application directory (app/staticfiles/admin/css/).

grax@remote:/var/www/pt/static$ rm -rf admin
grax@remote:~/django$ python3 collectstatic
125 static files copied to '/var/www/pt/static', 47 unmodified.
grax@remote:~/django$ cd /var/www/pt/static/admin/css
grax@remote:/var/www/pt/static/admin/css$ ls -l
total 120
-rw-r--r-- 1 grax grax  9114 Jun  1 23:21 autocomplete.css
-rw-r--r-- 1 grax grax 21207 Jun  1 23:21 base.css
-rw-r--r-- 1 grax grax  6584 Jun  1 23:21 changelists.css
-rw-r--r-- 1 grax grax  2929 Jun  1 23:21 dark_mode.css
-rw-r--r-- 1 grax grax   441 Jun  1 23:21 dashboard.css
-rw-r--r-- 1 grax grax  8953 Jun  1 23:21 forms.css
-rw-r--r-- 1 grax grax   958 Jun  1 23:21 login.css
-rw-r--r-- 1 grax grax  2694 Jun  1 23:21 nav_sidebar.css
-rw-r--r-- 1 grax grax 18533 Jun  1 23:21 responsive.css
-rw-r--r-- 1 grax grax  1785 Jun  1 23:21 responsive_rtl.css
-rw-r--r-- 1 grax grax  4694 Jun  1 23:21 rtl.css
drwxrwxr-x 3 grax grax  4096 Jun  1 23:21 vendor
-rw-r--r-- 1 grax grax 11900 Jun  1 23:21 widgets.css


grax@remote:~/django/app/staticfiles/admin/css$ ls -l
total 116
-rw-rw-r-- 1 grax grax  9114 May 19 16:42 autocomplete.css
-rw-rw-r-- 1 grax grax 20344 May 19 16:42 base.css
-rw-rw-r-- 1 grax grax  6395 May 19 16:42 changelists.css
-rw-rw-r-- 1 grax grax   796 May 19 16:42 dark_mode.css
-rw-rw-r-- 1 grax grax   380 May 19 16:42 dashboard.css
-rw-rw-r-- 1 grax grax   423 May 19 16:42 fonts.css
-rw-rw-r-- 1 grax grax  8944 May 19 16:42 forms.css
-rw-rw-r-- 1 grax grax   958 May 19 16:42 login.css
-rw-rw-r-- 1 grax grax  2619 May 19 16:42 nav_sidebar.css
-rw-rw-r-- 1 grax grax 18854 May 19 16:42 responsive.css
-rw-rw-r-- 1 grax grax  1741 May 19 16:42 responsive_rtl.css
-rw-rw-r-- 1 grax grax  3598 May 19 16:42 rtl.css
drwxrwxr-x 3 grax grax  4096 May 19 16:42 vendor
-rw-rw-r-- 1 grax grax 11297 May 19 16:42 widgets.css

So there’s a fonts.css in the app directory that collectstatic ignores, that the other CSS files query. And the file sizes in STATICROOT are different for some reason.

Browser console/network:

Try running collectstatic with the -c -v 3 options.

Also note that the order of the files being copied is dependent upon the order that the applications are defined in INSTALLED_APPS. If you have conflicting files in multiple directories, that could cause symptoms like this.

It didn’t work the first time, so I thought it was borked and continued poking at stuff. I ran it two more times, but didn’t notice that somewhere along this process it was now working. Questioning if maybe my eyes deceived me and it might have worked the first time around, actually.

At any rate, I didn’t modify any configs or move any files manually, nor run any other commands, so it must have been those arguments to collectstatic that did it somehow. Thanks for the help!


For the benefit of anybody else who wanders into this thread with a similar problem – for my case, I don’t think it was any conflict from INSTALLED_APPS. I looked at the output of the command Ken suggested manually and only found two css/base.css files - but they didn’t share any common folder structure beyond that. Additionally, I have django.contrib.admin at the very top of my INSTALLED_APPS.