This package allows you to log successful and failed login attempts on your django admin.
The full documentation is at https://django-admin-access-log.readthedocs.io.
Install Django Admin Access Log:
pip install django-admin-access-log
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'admin_access_log',
...
)
Add in your logging settings "login_logger_error" and "login_logger_success", with the handler of your choice, like this:
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"verbose_login": {
"format": "%(asctime)s :: %(message)s",
},
},
"handlers": {
"login_handler_error": {
"level": "ERROR",
"class": "logging.handlers.MemoryHandler",
"capacity": 200
},
"login_handler_success": {
"level": "INFO",
"class": "logging.handlers.MemoryHandler",
"capacity": 200
},
},
"loggers": {
"login_logger_error": {
"handlers": ["login_handler_error"],
"level": "ERROR",
"propagate": True,
},
"login_logger_success": {
"handlers": ["login_handler_success"],
"level": "INFO",
"propagate": True,
},
},
}
- Receiver for user_login_failed signal send by django when failed login attempt is tried.
- Receiver for user_logged_in signal send by django when login attempt is successful.
- get_client_ip function.
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
pip install -r requirements_dev.txt invoke -l
Tools used in rendering this package: