Custom admin page

Hello,

I created a page that allows me to modify some parameters in a json file.
this page extends admin/base_site.html.

fot the moment, i have added this to the urls
path("admin/parameters/", views.all_parameters, name="admin-parameters"),

but I have to type the full url to access it’s quite annoying.
I would like this page to be easily accessible from the django admin menu but I can’t find how to do it.

This is what the idea I have in mind looks like

The only facility I see for doing this would be to extend the AdminSite.get_urls() method. You’ll probably also want to read the source code in django.contrib.admin.sites.AdminSite, especially the comments in the admin_view method.

it’s mandatory to replace the override the default admin site ?

As far as I can tell - without actually having done or tried this myself - yes.

It’s the AdminSite object that builds that page.

Thanks for your help !

I succeeded to do what i want.
I’m not sure it was make properly but it works.

If it can help someone, here’s what I did to get there

I’ve changed the default site like explanations here: Le site d’administration de Django | Documentation de Django | Django

And for my custom AdminSite i’ve made this:

class MyAdminSite(admin.AdminSite):
    site_header = "Custom Administration"
    def get_urls(self):
        urls = super().get_urls()
        my_urls = [path("settings/", self.admin_view(self.settings_view), name="settings")]
        return my_urls + urls

    def get_app_list(self, request, app_label=None):
        app_list = super().get_app_list(request, app_label)
        if app_label is None or app_label == 'general':
            app_list.append(
                {
                    "name": "General",
                    "app_label": "general",
                    "models": [
                        {
                            "name": "Settings",
                            "object_name": "settings",
                            "admin_url": "/admin/settings",
                            "view_only": True,
                        }
                    ],
                }
            )
        return app_list

    def settings_view(self, request):
        context = dict(self.each_context(request))
        context['parameters'] = config.get_parameters()
        return TemplateResponse(request, 'admin/settings/settings.html', context)

And the result: