简体   繁体   中英

How do I get the number of active users on my django website?

I want to display the number of active visitors on my website, I tried using django-tracking , django-active-users but none of them worked because they are outdated. I am using Django 3.0.8 and all of those modules aren't supported with django3.

I also tried doing this with Google analytics but their real-time reporting API is in limited beta and not open to everyone. Is there any way I can get this to work using Django active sessions or something?

Create a DailyCount model which has date(DateField) , active_users(PositiveIntegerField) .

Then use celery periodic tasks with a function that is triggered at hour=0, minute=0 , ie, every day.

Create a DailyCount instance in the triggered function.


Whenever a user visits the site for the first time that day, increase DailyCount.active_users by 1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM