Skip to content Skip to sidebar Skip to footer

Django 3.1 | Admin Page Appearance Issue

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. admin.py Can someone help m

Solution 1:

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

Solution 2:

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.

Solution 3:

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.

@Tom Carrick, you are right btw.

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

Solution 4:

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',
]

Solution 5:

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.

Post a Comment for "Django 3.1 | Admin Page Appearance Issue"