On 04-03-14 13:28, Some Developer wrote: > Hopefully someone here will be able to point me in the right direction. > > Basically I want to be able to view which users are viewing a page at > any given time and I want to be able to update it in real time using > JavaScript but I'm at a loss as to how to track which users are viewing > any given page in Django.
So enter some long-polling javascript that notifies the server every X seconds that some user is still at the page you're tracking. > So for instance if I had mydomain.com/page/ I'd like a little box on the > top of the page saying "Page being viewed by users: xxx and yyy" and > then when one of those users navigates away from the page the box > updates to remove that user from the list. This means that apart from the "I'm still here", you also need a "Who's here at" as well. > I'm not sure if I have described what I want clearly enough so if you > need any more information let me know. Any help is appreciated :). So for each page you want to track: use a settimeout loop in javascript to: - do a POST to some mini-view where you register who's at some page. You can use the REMOTEUSER (auth-user) to find out who's who, and the Referer header to see where they are in your site. - this POST returns some data (json?) that will tell you who else is there. You can now update your DOM to reflect this information. If you don't want or care about authenticating users, you can't know who is actually at the page, just the number of people, and their IP addresses, browser version, etc. Of course some people have done this before. Maybe check out TogetherJS for more real-time collaboration goodies. -- ________________________________________________________________ Paul J Stevens pjstevns @ gmail, twitter, github, linkedin www.nfg.nl/i...@nfg.nl/+31.85.877.99.97 -- 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+unsubscr...@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. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5315CFCB.2040907%40nfg.nl. For more options, visit https://groups.google.com/groups/opt_out.