Admin layout getting too bulky - what to do?

51 views
Skip to first unread message

Mike Dewhirst

unread,
May 2, 2021, 3:27:19 AM5/2/21
to Django users
My project has a central table with many 1:n and n:m sub-tables. I mean
lots of them. It takes forever to keep scrolling up and down the page to
find the section of interest and then maybe scroll through some records
in that section before clicking (SHOW) to reveal data.

Is there a way I can do a sidebar of links which take the user to
specific sections?

I have had a look at the contrib layout and it doesn't appear obvious
what to do. Especially since they don't pay me enough to play with js ;-)

Has this been solved before?

Thanks for any hints

Cheers

Mike

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.


OpenPGP_signature

Mike Dewhirst

unread,
May 3, 2021, 2:57:25 AM5/3/21
to Django users
OK - I've now looked at some Django Admin templating systems and they
all seem to solve a different problem than the one I need to ... which
is ...

Consider the Admin main menu seen at the /admin url after login. If you
click any of the links they take you to a single page with a list of
records. So my need is for a fixed vertical sidebar with the same links
which take you to the same list pages. The vertical sidebar should
remain unchanged and unmoved on the list page in case the user clicked
the wrong link.

The next step is to select a record from the list. When that page opens
for the record, the sidebar of links should change to the named headings
on that page. When a heading is clicked the page should relocate itself
so that heading is at the top. The sidebar of links should remain
unchanged and unmoved in case the user wishes to relocate to a different
heading. Much like the Django documentation except the sidebar should
stay where it was when clicked!

At the moment, those headings don't have urls within the page. And the
(Show/Hide) urls are all just a lone hash '#'.

Therefore my problem is to understand how to include heading name
anchors and construct a list of urls (including 'top' and bottom') for
such a sidebar. And of course to understand how to make such a sidebar
in the first place.

Where might I begin my research?

Thanks

Mike
OpenPGP_signature

Derek

unread,
May 3, 2021, 5:42:35 AM5/3/21
to Django users
Re "So my need is for a fixed vertical sidebar with the same links which take you to the same list pages."

This is what I use Django Suit for -  it can be located at the top or side and remains in place across all admin pages.  You can add your own items to the menu (and these can point to non-admin pages - for example, I point to a page of report URLs which is a non-standard admin page) ; I have never added menu items "on the fly" so am not sure this is possible.

I cannot understand your requirement statement "When that page opens for the record, the sidebar of links should change to the named headings on that page. When a heading is clicked the page should relocate itself so that heading is at the top"  at all, sorry. Maybe a follow-up post with a picture (== 1000 words)?

Derek

Mike Dewhirst

unread,
May 3, 2021, 10:44:26 AM5/3/21
to django...@googlegroups.com
Derek

My phone doesn't do interspersed responses well, so my apologies for top posting. 

The record to which I refer is any one of those in any list page.

After clicking one, if that record has any 1:1, 1:n or n:m related records, their verbose_name_plural names will be displayed as dumb headings with related records appearing below with show/hide links as well as an 'Add another ...' link.

I'd like to see the sidebar display links to those (currently) dumb headings and fetch them to the top.

Hope that clarifies what I meant despite what I said :-)

I'll  have a look at Django suit in the morning. Thanks for the heads up.

Cheers

Mike 



--
(Unsigned mail from my phone)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ec2ed88b-564c-477a-8ebe-067c2d975bf7n%40googlegroups.com.

Chetan Ganji

unread,
May 3, 2021, 10:58:45 AM5/3/21
to django...@googlegroups.com

I am not sure how useful this will be. You can check it out. 
https://django-mptt.readthedocs.io/en/latest/index.html


Regards,
Chetan Ganji
+91-900-483-4183


Mike Dewhirst

unread,
May 4, 2021, 11:58:20 PM5/4/21
to django...@googlegroups.com
On 4/05/2021 12:57 am, Chetan Ganji wrote:
>
> I am not sure how useful this will be. You can check it out.
> https://django-mptt.readthedocs.io/en/latest/index.html
> <https://django-mptt.readthedocs.io/en/latest/index.html>
>


Thanks Chetan. I had a look and don't think I have the brainspace for
that. What I mean is, I can't quite see how it would help.

Cheers

Mike


>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji....@gmail.com <mailto:ganji....@gmail.com>
> http://ryucoder.in <http://ryucoder.in/>
>
>
> On Mon, May 3, 2021 at 8:13 PM Mike Dewhirst <mi...@dewhirst.com.au
> <mailto:mi...@dewhirst.com.au>> wrote:
>
> Derek
>
> My phone doesn't do interspersed responses well, so my apologies
> for top posting.
>
> The record to which I refer is any one of those in any list page.
>
> After clicking one, if that record has any 1:1, 1:n or n:m related
> records, their /verbose_name_plural/ names will be displayed as
> <mailto:django-users...@googlegroups.com>.
> <https://groups.google.com/d/msgid/django-users/ec2ed88b-564c-477a-8ebe-067c2d975bf7n%40googlegroups.com?utm_medium=email&utm_source=footer>.
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/60900c1e.1c69fb81.5d1d7.d62cSMTPIN_ADDED_MISSING%40gmr-mx.google.com
> <https://groups.google.com/d/msgid/django-users/60900c1e.1c69fb81.5d1d7.d62cSMTPIN_ADDED_MISSING%40gmr-mx.google.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMKMUjt18JXjHxfu%3D2Xsp5oEbxh63DPAPQ__9vMYD4b_NHd7xQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMKMUjt18JXjHxfu%3D2Xsp5oEbxh63DPAPQ__9vMYD4b_NHd7xQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
OpenPGP_signature

Mike Dewhirst

unread,
May 5, 2021, 12:01:52 AM5/5/21
to django...@googlegroups.com
On 3/05/2021 7:42 pm, Derek wrote:
> Re "So my need is for a fixed vertical sidebar with the same links
> which take you to the same list pages."
>
> This is what I use Django Suit for -  it can be located at the top or
> side and remains in place across all admin pages. You can add your own
> items to the menu (and these can point to non-admin pages - for
> example, I point to a page of report URLs which is a non-standard
> admin page) ; I have never added menu items "on the fly" so am not
> sure this is possible.

Django suit looks interesting, thanks for that. I'll dig a little deeper
but first I have a related question for which I'll start another thread
after I reach a probable dead end in my current digging.

Cheers

Mike
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ec2ed88b-564c-477a-8ebe-067c2d975bf7n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/ec2ed88b-564c-477a-8ebe-067c2d975bf7n%40googlegroups.com?utm_medium=email&utm_source=footer>.


OpenPGP_signature

Derek

unread,
May 5, 2021, 4:20:34 AM5/5/21
to Django users
"I'd like to see the sidebar display links to those (currently) dumb headings and fetch them to the top."

As I said, you'd need to see if it possible to update Django Suit on-the-fly.

Alternately, you could look at making a model-specific template layout (e.g. https://realpython.com/customize-django-admin-python/ ) - but to make it generic to apply across all pages would require a significantly deeper level of admin know-how than I have.  Maybe there are Django admin plugin projects you could look at for inspiration? 

Mike Dewhirst

unread,
May 5, 2021, 5:19:51 AM5/5/21
to django...@googlegroups.com
On 5/05/2021 6:20 pm, Derek wrote:
> "I'd like to see the sidebar display links to those (currently) dumb
> headings and fetch them to the top."
>
> As I said, you'd need to see if it possible to update Django Suit
> on-the-fly.
>
> Alternately, you could look at making a model-specific template layout

Thanks again for another reference. Most seems familiar but I'll go back
over it.

Wanting a link to a particular part of a page, I figured I needed a name
anchor (<a name="model">) where "model" is the 1:n, n:m related model.
That name anchor needs to be in the location of verbose_name_plural
because that's what Django displays in the Admin just ahead of all the
related records.

I tried that in the admin with, for example ...

verbose_name_plural = mark_safe('<div><a name="links"></div>Useful links')

... and it almost worked! With a few link records in place, the first
one lost its (Show/Hide) button and although I could see its name there
was no way to reveal the record. Same for all the other 1:n and n:m
related records.

It did work as a name anchor by way of bringing up that section to the
top of the browser window.

The urls were in a separate page listing all the sections, not in a
sidebar or drop-down menu as I would really like. I did it that way as a
stepping stone. Thought testing name anchors might be a simple first
step. Glad I didn't start from the other end and discover the
disappearing top record at the finishing post!

Cheers

Mike

> (e.g. https://realpython.com/customize-django-admin-python/ ) - but to
> make it generic to apply across all pages would require a
> significantly deeper level of admin know-how than I have.  Maybe there
> are Django admin plugin projects you could look at for inspiration?
>
> On Monday, 3 May 2021 at 16:44:26 UTC+2 Mike Dewhirst wrote:
>
> Derek
>
> My phone doesn't do interspersed responses well, so my apologies
> for top posting.
>
> The record to which I refer is any one of those in any list page.
>
> After clicking one, if that record has any 1:1, 1:n or n:m related
> records, their /verbose_name_plural/ names will be displayed as
> <https://groups.google.com/d/msgid/django-users/ec2ed88b-564c-477a-8ebe-067c2d975bf7n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/05ce98b5-2226-471b-96ce-baf0912ce129n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/05ce98b5-2226-471b-96ce-baf0912ce129n%40googlegroups.com?utm_medium=email&utm_source=footer>.
OpenPGP_signature
Reply all
Reply to author
Forward
0 new messages