I am Building a BlogApp and I am stuck on a Problem
What i am trying to do
I am trying to access only one user which i have opened the profile
online status in template. BUT it is showing all the active users.
What i am doing
I am using online_users_activity
to know which user is online.I am using This django_online_users
The Problem
It is showing all the users that are online.
views.py
def online(request,user_id):
user_status = online_users.models.OnlineUserActivity.get_user_activities(timedelta(hours=87600))
users = (user for user in user_status)
context = {'users':users}
return render(request, 'online.html', context)
I don't know what to do.
Any help would be Appreciated.
You can simply annotate whether the user is online or not yourself by checking if
last_activity
is greater than some calculated time using Conditional Expressions:Now the user whose profile you are checking would have an annotated field
is_online
so you can check as: