Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django tracking recent online users

Tags:

django

session

Is there any way to track active users in django?

I have seen a few online solutions to the problem:

http://mpcabd.igeex.biz/get-online-users-in-django/

being one of those. But it seems rather odd to modify the model structure just to solve this simple problem. I would like to know if there is any quick solution around.

The last_login field in django auth is also not of much use since it only records the time when a user logs in and the field is not updated if the user has been in session for a long time

like image 201
saurabh Avatar asked Oct 11 '09 12:10

saurabh


People also ask

How can I see online users in Django?

But the correct way to check if a user is logged in or not is to use : request. user. is_authenticated. This will return True if the person is logged in other wise False.

How do you track and manage pages a user visits in Django history app?

Enter the username and password of the superuser you just created with the manage.py command to log in. Next, you will see the Django admin dashboard. The "User visit log" has already been added to the Admin. Click on the "User visits" link.

How can I tell if someone is online using Django rest?

Write a piece of Javascript which will send a dummy request to server. Put this to repeat on say 60 or some seconds. As long as you are receiving requests you know page is on. Then you can check if that user is authenticated.


1 Answers

I'm the one who wrote that blog :)

I didn't modify the User model, I extended it, it is the same as profiles, but I wanted to make it in a way that if you have already defined a profile you can still use my method.

I think extending the User model is the best way to handle it, I don't know if there are any points against it.

like image 191
mpcabd Avatar answered Sep 21 '22 00:09

mpcabd