Django Admin now showing model list in iframe — what changed? - django

I have built a Django application with a custom interface. It hasn't been changed in a couple of years.
These (previous) servers are running Django 3.0.8.
Recently I set up a new server, and the Django Admin interface now shows the model list in a scrolling iframe, and long tables on the right side are also scrolled independently of the page.
This server is running Django 3.2.3.
I don't like the new interface, but it more importantly it will require an extensive rewrite of our custom admin css.
Can anyone point me to information about the change, or tell me if there is a setting to disable it?

I found the answer in this Stack Overflow answer. I will leave this question up because the other answer doesn't mention iframes.
Django 3.1 added the new scrolling sidebar in an iframe.
To disable it add the following to the root urls.py file:
from django.contrib import admin
admin.autodiscover()
admin.site.enable_nav_sidebar = False
The 3.1 Release Notes say:
The admin now has a sidebar on larger screens for easier navigation. It is enabled by default but can be disabled by using a custom AdminSite and setting AdminSite.enable_nav_sidebar to False.
Reference links from the original answer:
Django 3.1 release notes
The Django admin site

Related

How to go about enabling side scrolling in Wagtail admin site

I have been tackling a particular design issue with Wagtail admin. Thus far I have not found a way to enable side scrolling admin listing pages. I want to extend my user model with more data about the users (e.g., occupation, education, address, and so on). While extending Wagtail with some models for a particular project, I noticed Wagtail admin listing pages do not automatically activate sides crolling as Django admin does.
I have looked at Wagtail hooks doccumentation but apparently there isn't a straightforward way to do that. I don't think it would be wise to mess with core css. Does anyone have an idea on how to customize css to enable that?
See pictures below:
This is how Django admin handles it. We can add filters while the table adjusts itself activating side scrolling.
Wagtail Bakery demo user model has few fields. So the listing admin page does not need to side scroll. I have not tested adding filters on this page yet, but I am assuming it will work just as it did to my other models.
This is how my admin page looks like when using filters. The table does not activate side scrolling and gets messed up when I use filters.
I'd appreciate any help poiting the way to best tackle this problem. Thus far I found this and this answers to similar, though not exaclty the same, problems with Wagtail admin design.

Django admin page layout changed with new version

I am working on an existing django project where admin console is extensively used.
With my latest run of package upgrade for my application admin page layout has changed.
Models have started appearing on all the pages, leaving a small space to display form fields.
For example this is how form page look like now:
Original Form view was occupying the whole page like this:
Any clue on what has been changed and which setting to change to get back the original view?
From the django-3.1 release notes,
The admin now has a sidebar on larger screens for easier navigation.
It is enabled by default but can be disabled by using a custom
AdminSite and setting AdminSite.enable_nav_sidebar
to False.
You can refer Customizing the AdminSite class - (django doc) to know more about customizing the AdminSite
Try this, open your browser and clear all the history then login back in again and it should work. I am sure the browser has cached an old version of Django admin.
I had the same problem when using version 3.1. I started a new demo app with version 2.2 to demonstrate something and when I got back to version 3.1 I got that issue, So what I did was just clear the browser history and everything came to its original state.

Django admin not loading individual app pages

I've just set up a new local version of my django application, and all working fine until I checked on the django admin.
127.0.0.1:8000/admin works fine and brings up the usual Django Admin homepage with full list of apps, but when I click into any of the individual app elements it breaks. The URL changes, but instead of displaying that app's admin site it shows an oddly rendered version of the admin homepage, with the app list collapsed on left side of screen (see screenshots below)
Can't immediately see which parts of codebase could be relevant here, so please request copies of any code you want to see.
The correctly displayed Django Admin homepage
How it renders when I click into any of the individual app/model admin sites
As above, with list of all apps expanded from left
This happened to me when I upgraded to django 3.1.
Set admin.site.enable_nav_sidebar = False on your admin.py file.
from django.contrib import admin
admin.site.enable_nav_sidebar = False
Actually the admin does load the pages for every model but the nav_sidebar takes all the space. If you zoom out long enough you'll see the models and forms are there.

Django-Machina forum panel not showing in wagtail admin panel

I have a wagtail project being developed, essentially a blog with a forum. I chose django-machina as the forum I want to use because of how modular it is and how well it integrates into existing projects.
I followed the instructions in the documentation without issue, and the install was a success. I can access the app by going to /forum on my project.
However, the next step in the documentation refers to using the forum admin panel. My wagtail admin menu does not have a section for forum and I can't access the django admin panel as it is a wagtail project.
Where exactly can I access the django-machina forum admin panel in a wagtail project? Or would I have to recreate it somehow?
Jake, it's not so difficult. Let your project be named 'my_project'. So than we should go to my_project/my_project/urls.py. There we see something like this:
url(r'^django-admin/', admin.site.urls),
And what this string say to us? It show how to get the vanilla django-admin! Ok, now just go to your.site/django-admin and run your forum! ;)
Unless the documentation specifically mentions Wagtail, it's more likely that the admin panel shows up in the Django admin backend rather than the Wagtail one. On a standard Wagtail project this is found at the URL /django-admin/, but it depends on what you have specified in your project's urls.py file.

Django Admin models that appear in app section, but not on the admin home

I've inherited some code that I need to add some new models (and admin models) to, and I've noticed a slight oddity.
There are several models within an app, that do not appear to the user on the admin interface on the app's section home page (the page you land on after logging in to the admin site), but that do appear on the app's page of admin site. It seems that when I add a new model to the app, and register it to the admin site, it behaves in this way.
Is this a feature of Django's admin that I'm not familiar with, or do I need to hunt for some custom code that's controlling this?
To be clear, imagine an app (called 'app'), with 2 models (Model1, and Model2) registered in the admin interface. You log into the admin site, and on the main page, you see the 'App' header, and underneath it, is only Model1. You click on the 'App' header, the breadcrumb nav now says "Home > App", and on that page you then see both Model1 and Model2. How has this been done? How can I configure it? Or is something broken?
I have discovered that in the INSTALLED_APPS there were several apps I wasn't familiar with, but two were called "grappelli" and "grappelli.dashboard".
Noticing furhter down in settings.py there was a setting:
GRAPPELLI_INDEX_DASHBOARD = "the_app.dashboard.AdminDashboard"
I found the AdminDashboard class and sure enough, in there, is a definition of what models appear on the 'dashboard' of the admin site.