Ability to change LoginView inside custom AdminSite

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Ability to change LoginView inside custom AdminSite

Nikita Krokosh

Hello everyone.


There's a way to set your own AdminSite class as said in docs:

https://docs.djangoproject.com/en/3.0/ref/contrib/admin/#overriding-the-default-admin-site


But I also want to change login view behavior.

I want to replace LoginView in

    django.contrib.admin.sites.AdminSite.login

method (by analogy with for example login_form parameter in the same AdminSite class).


I need it to write custom logic in form_valid method, and it looks dirty and unnecessary to copy-paste whole login view code.

Can project code be improved this way?


Best Regards.



--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/0a5f010a-df61-a7ce-e62f-281108c8dfd8%40gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Ability to change LoginView inside custom AdminSite

Dipankar B
Read documentation for customization. I hope you need to pass template parameter and form class. That's all.

On Fri, May 15, 2020 at 7:44 PM Nikita Krokosh <[hidden email]> wrote:

Hello everyone.


There's a way to set your own AdminSite class as said in docs:

https://docs.djangoproject.com/en/3.0/ref/contrib/admin/#overriding-the-default-admin-site


But I also want to change login view behavior.

I want to replace LoginView in

    django.contrib.admin.sites.AdminSite.login

method (by analogy with for example login_form parameter in the same AdminSite class).


I need it to write custom logic in form_valid method, and it looks dirty and unnecessary to copy-paste whole login view code.

Can project code be improved this way?


Best Regards.



--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/0a5f010a-df61-a7ce-e62f-281108c8dfd8%40gmail.com.


--
Warm Regards,
Dipankar B.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAFdBwp8-RKCY3mqXtq0sEqnBXL2pFNTZNJda_qpOQXCrM_UvQQ%40mail.gmail.com.