Configurable landing page in admin site

89 views
Skip to first unread message

Gagan Deep

unread,
Dec 23, 2020, 10:01:03 AM12/23/20
to Django developers (Contributions to Django itself)
Greetings of the day,

I have use case where I want to show a custom landing page after a user logs into the admin site. One way to do it will be to override the index_template attribute of AdminSite, but doing so will not let me use the index page generated by Django admin . 

I want to keep the index view intact while also providing a custom landing page logged in users on Django's admin site. I think such feature will be helpful for all users of Django. 

Best, 
Gagan Deep

Adam Johnson

unread,
Dec 23, 2020, 10:07:22 AM12/23/20
to django-d...@googlegroups.com
You can do this already by changing where the login redirects to in your custom AdminSite class

def login(self, *args, **kwargs):
        response = super().login(*args, **kwargs)
        if isinstance(response, HttpResponseRedirect):
            response = HttpResponseRedirect("/custom-page/")
        return response

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/c2774449-3a4d-45ad-99d1-0ef998154827n%40googlegroups.com.


--
Adam

Gagan Deep

unread,
Dec 24, 2020, 10:05:25 AM12/24/20
to Django developers (Contributions to Django itself)
Thanks for sharing Adam. This should take care of my use case. 

Do you think there can be a potential use for introducing a setting/attribute dedicated for adding a landing page? 

Best, 
Gagan Deep

Adam Johnson

unread,
Dec 24, 2020, 11:13:54 AM12/24/20
to django-d...@googlegroups.com
No I don’t think so given that customisation is already possible.

--
Adam
Reply all
Reply to author
Forward
0 new messages