'How do I filter models from the Django admin sidebar while keeping them on their children's change page form?
I have a setup that looks like this:
Because 'Charities' and 'Interventions' aren't meant to be edited except from the Evaluations and Max Impact Fund Grants page, I don't want to show up in the navbar menu. I've been scraping through the bowels of Django looking for a way to do this, and the least hacky way I can find is overwriting the django.contrib.admin.AdminSite.get_app_list function, such that after it's assembled the app_list array, I modify in place the element containing the models to delete the offending two.
The two problems with this are 1) it's incredibly hacky and 2) it doesn't actually work - I end up with an empty navbar with the message that I don't have permission to modify any objects (I confirmed that the app_list post-modification had the rest of the elements).
I feel like there's probably some trivial approach like 'define the app_navbar_models variable to have an exclude list on one of your admin objects', but I have failed to find such an approach either on StackOverflow or indicated in the Django code. Did I miss something?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|