get all current active connected users

71 views
Skip to first unread message

Fabio C. Barrionuevo da Luz

unread,
Dec 9, 2015, 7:43:50 AM12/9/15
to django...@googlegroups.com
hello, 
Django provide any API for get all users who are currently connected?

I need to run some scheduled tasks for users who are not connected and did not understand how I can get the users with active login via Session

--
Fábio C. Barrionuevo da Luz
Palmas - Tocantins - Brasil - América do Sul


Blog colaborativo sobre Python e tecnologias Relacionadas, mantido totalmente no https://github.com/pythonclub/pythonclub.github.io .

Todos são livres para publicar. É só fazer fork, escrever sua postagem e mandar o pull-request. Leia mais sobre como publicar em README.md e contributing.md.
Regra básica de postagem:
"Você" acha interessante? É útil para "você"? Pode ser utilizado com Python ou é útil para quem usa Python? Está esperando o que? Publica logo, que estou louco para ler...

Jani Tiainen

unread,
Dec 9, 2015, 7:55:22 AM12/9/15
to django...@googlegroups.com
Hi,

This is really problematic domain since as you know, Django works on HTTP request-response cycle. After cycle is finished there is absolutely no way to know "who is logged on".

So first you have to determine factors that make up "currently active user". Then you have to track that information somehow and after that it's possible to gather a list of active/inactive users.

Jon Ribbens

unread,
Dec 9, 2015, 8:37:54 AM12/9/15
to Django users
On Wednesday, 9 December 2015 12:55:22 UTC, Jani Tiainen wrote:
This is really problematic domain since as you know, Django works on HTTP request-response cycle. After cycle is finished there is absolutely no way to know "who is logged on".

So first you have to determine factors that make up "currently active user". Then you have to track that information somehow and after that it's possible to gather a list of active/inactive users.

Users have a last_login field so you could easily say "users who have logged in in the last 24 hours" or whatever. 

Jani Tiainen

unread,
Dec 10, 2015, 4:25:51 AM12/10/15
to django...@googlegroups.com
Hi,

That last login field only applies when user really logs in. (IOW you call login() function from django.contrib.auth). After that user is persisted to session so there is no need to authenticate per request.

Now if you have longer sessions than 24 hours user will stay logged in (I think default session TTL is 2 week after last modification). So that would still give troubles that users may have been active in last few seconds but not logged in for a few days.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7c5f0620-c094-4667-b474-82a23f432fa1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

Jani Tiainen
Reply all
Reply to author
Forward
0 new messages