def get_all_logged_in_users():
# Query all non-expired sessions
sessions = Session.objects.filter(expire_date__gte=datetime.now())
uid_list = []
# Build a list of user ids from that query
for session in sessions:
data = session.get_decoded()
uid_list.append(data.get('_auth_user_id', None))
# Query all logged in users based on id list
return User.objects.filter(id__in=uid_list)
On Sunday, March 3, 2013 11:49:09 AM UTC-5, frocco wrote:
I want to list users currently on our site.Would I use the last login date time?If so, what should the query look like?Thanks
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment