40

Today I have updated Django to latest version 3.1.

But for some reason when the logged in to admin page, all I cans see is a weird looking admin page.

Django Admin screenshot

admin.py

admin.py

Can someone help me what went wrong or what are things I need to modify to get back to original admin page.

Thanks in advance

Ro Segura
  • 67
  • 9
Raghavendra
  • 521
  • 5
  • 11

5 Answers5

63

In your projects' root urls.py file, simply add the below code to disable the new sidebar feature.

from django.contrib import admin

admin.autodiscover()
admin.site.enable_nav_sidebar = False

Reference:

  1. https://docs.djangoproject.com/en/3.1/releases/3.1/#django-contrib-admin
  2. https://docs.djangoproject.com/en/3.1/ref/contrib/admin/#django.contrib.admin.AdminSite.enable_nav_sidebar
The Go Company
  • 741
  • 4
  • 6
  • 6
    Thanks for responding. When I opened in Incognito mode, everything is working fine. So I cleared all cookies, caches and other stuff in normal browser and is working fine. I really liked the new sidebar feature. I'd like to keep it, don't want to change. Thanks again. – Raghavendra Aug 08 '20 at 15:32
  • 2
    There's no need to turn off the feature for what looks like a browser cache issue. – Tom Carrick Aug 19 '20 at 18:10
  • Agree 100%, I also like the new feature and it looks good and works well; but for those who are averse to the change, this solution will just "switch it off" and display things the good old way. – The Go Company Sep 04 '20 at 08:55
  • 1
    Dang it. This was driving me nuts. However collectstatic and clearing my cache did not fully fix it. If I resize my browser window to lesser width, eventually the correct forms show up. This seems like it could be useful but the implementation appears to have something to be desired..... – Micah Yoder Sep 15 '20 at 03:37
  • It resolved the issue. My django is 3.1.5. Thank you for provided the information. – Shirley Jun 12 '21 at 03:26
  • This was the issue for me too. I had already found that disabling the css sticky feature fixed it. This made it permanently off – Joel G Mathew Aug 26 '21 at 04:44
  • Solved it for me, thanks a bunch! – shadow Oct 14 '21 at 19:59
  • This solution seems to be most effective one, I don't know the reasons but the other answers didn't work with me... Thanks. – Yalchin Mammadli Oct 17 '21 at 22:46
18

It looks like one of two problems.

  1. Your browser is caching the CSS / JS from the old version, in which case clear your cache and reload.

  2. You didn't run ./manage.py collectstatic after updgrading.

Judging from your comment, it's probably the former.

fedorqui
  • 275,237
  • 103
  • 548
  • 598
Tom Carrick
  • 6,349
  • 13
  • 54
  • 78
9

Your browser is caching the CSS / JS from the old version, in which case clear your cache and for that, you need to do Force Reload.

To Force Reload in Chrome use Hold the Ctrl key and press the Reload button. Ctrl + F5 also works

and for Mozilla Firefox Ctrl + Shift + R

For development/Production ie. on server just run

python3 manage.py collectstatic

This will bring all the html and css files for you and put that in static folder, that you have defined in settings.py.

Deepanshu Mehta
  • 1,119
  • 12
  • 9
2

After upgrading Django, I had an issue with the sidebar, as above.

Clearing cache didn't work for me. Neither did running collectstatic. Adding this to settings.py did, followed by collectstatic:

STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]
devdrc
  • 1,853
  • 16
  • 21
  • Thanks @devdrc. This is the only solution that worked for me. This lead me to discover that some of the directories listed in my `STATIC_DIRS` had outdated files that were conflicting (and winning over) with those of the django3 admin app. In my case, your proposed solution helped me find the problem but removing `django.contrib.staticfiles.finders.FileSystemFinder` from the list of `STATICFILES_FINDERS` would have created other different problems. – ariera Aug 13 '21 at 09:50
1

One way of avoiding this browser cache problems is using Django's ManifestStaticFilesStorage that is not enabled by default:

STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'

When the content of the static file changes, so will the url to the file.

Manel Clos
  • 1,785
  • 2
  • 19
  • 15