0

I want to add custom views and templates to Admin and wrote this:

# in models.py
class MyAdminSite(admin.AdminSite):

    def my_view(self, request):
        return HttpResponse("Test")

    def get_urls(self):
        from django.urls import path

        urlpatterns = super().get_urls()
        urlpatterns += [
            path('my_view/', self.admin_view(self.my_view))
        ]
        return urlpatterns


admin.site = MyAdminSite()

# and in apps.py
class MyAdminConfig(AdminConfig):
    default_site = 'ToDoDashboard.admin.MyAdminSite'

I have registered all the models and I see them in my custom Admin panel. However, the section with users and groups has disappeared. How to get it back?

EngineerSpock
  • 2,575
  • 4
  • 35
  • 57
  • Does this answer your question? [Auto register Django auth models using custom admin site](https://stackoverflow.com/questions/32612400/auto-register-django-auth-models-using-custom-admin-site) – tim-mccurrach Jun 19 '20 at 22:16
  • This is a duplicate of https://stackoverflow.com/questions/32612400/auto-register-django-auth-models-using-custom-admin-site. The second answer there provides an easy way of sorting this. The accepted answer provides a more comprehnsive solution. I personally think if all you want is the auth models, the second answer is simpler and better. – tim-mccurrach Jun 19 '20 at 22:17

0 Answers0