Django execute a function after django.contrib.auth.login
-
13-02-2021 - |
Question
I am using Django's default authentication system to run my website. So whenever a user logs in in urls.py I have -
(r'^login/$', 'django.contrib.auth.views.login'),
I guess django uses django.contrib.auth.login
& django.contrib.auth.authenticate
to login.
Now as part of some requirement I am needed to run some function calls just after a user logs in. How do i do that ?
Solution
Just include a signal function. Whenever a user logs in, django fires a signal and your function will be called.
Refer the documentation on auth signals.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow