Django app which keep track of user login history.
Project description
dj-user-login-history
A Django app which keep track of user login history.
How to install
pip install dj_user_login_history
Usage
- Add
login_historyapp to INSTALLED_APPS
INSTALLED_APPS = [
...
'login_history',
...
]
- Migrate database:
python manage.py migrate
- Now all your user's login history will be tracked to a model called LoginHistory
- You can check a user's active logins:
user.active_logins
- You can add
login_history.urlsto your project url to see an example page explaining the user login histores. - For better understanding, read following code:
def login_histories(request):
if not request.user.is_authenticated:
return HttpResponse("<h1>Please login to see your login histories</h1>")\
active_logins = request.user.active_logins
active_logins_html = ""
for login in active_logins:
active_logins_html += f'<li>{login.ip} - {login.date_time} - {login.user_agent}</li>'
return HttpResponse(
f"""
<h1>Active Logins</h1>
<ul>
{active_logins_html}
</ul>
"""
)
- Use the
ipto grab more information directly from the Frontend instead of backend, it'll optimize performance. There're huge JS library which do the work, use any one of them.
NB: When you write your own login view, make sure you log the user in using django login
from django.contrib.auth import login as django_login
django_login(request, user)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dj-user-login-history-1.0.6.tar.gz.
File metadata
- Download URL: dj-user-login-history-1.0.6.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ffa4e7b07ad1438915edb25f096167882eb4fa0c60d91f1bc18995c7f68efca
|
|
| MD5 |
b4cecac6efbe4c469325125580b014cd
|
|
| BLAKE2b-256 |
88f9712603c73a8cfb90c7c66a157dda11d6ab90872dd7d92f5f96839eeaa3a8
|
File details
Details for the file dj_user_login_history-1.0.6-py3-none-any.whl.
File metadata
- Download URL: dj_user_login_history-1.0.6-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e69798f765a75f0f01e4ba1677ead8b8abf20f7335608455c638b314fccceb5b
|
|
| MD5 |
d6552b3431eb78f42654a830351ef51c
|
|
| BLAKE2b-256 |
ec2c3f6f72949a45a8829afae285623e872c96b01ba35bf6c52c4766b9427773
|