How do I send available_apps in context to a view that is outside the admin panel in Django?

How can I get an application list like in get_app_list method in classy AdminSite?

I try to do it this way, but then I get an empty list.

from django.contrib.admin.sites import AdminSite

    def change_view(self, request):
        ...

        context = {
            ...
            'available_apps': AdminSite().get_app_list(request)
        }
        return render(request, 'parts/part_form.html', context=context)

I need this to display the admin side menu outside the admin panel.

You're calling AdminSite, I'm not sure but that might be incorrect according to docs.

Does AdminSite.get_app_list(request) work?

Try this:

from django.apps import apps

for app in apps.get_app_configs():
    print(app.verbose_name)
Back to Top