How to determine if user is currently active on site in Django
There are several ways to determine user activity:
1) Use javascript to send periodic requests to server. 
+: You will be able to determine user activity despite he actively working on site or just keep open window.
-: Too many requests.
2) Use django middleware
-: Can`t determine user activity if he keeps only open window
3) Use asynchronous framework to keep long-lived connection. For example tornado.
It is cleanest way but the most labor-intensive.
Is there a way to see if a user is currently logged in and active on a site?
For example, I know you can check the authentication token of the user and see if he is still 'actively logged in', but this doesn't tell me much, since the user could technically be logged in for two weeks, though only actively on the site for one minute of that duration. last_login would be equally unhelpful.
What would be a good method in django to check to see if the user is currently active? I have done this in Google Analytics, but was wondering how I could do an entirely-django approach.