Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close

django-last-seen

Keep trak of when a user has been last seen on a website. The last seen time is kept on the database

The app is ready for django 1.5, it uses the AUTH_USER_MODEL setting to get the user model,

Installation

  1. Install with pip install django-last-seen" or add "last_seen" directory to your Python path.
  2. Add "last_seen" to the INSTALLED_APPS tuple found in your settings file.
  3. Add 'last_seen.middleware.LastSeenMiddleware' to MIDDLEWARE_CLASSES tuple found in your settings file.
  4. Run manage.py syncdb to create the new tables

Usage

To get when a user has been last seen:

from last_seen.model import LastSeen

seen = LastSeen.object.when(user=user)

To save a last seen user without the middleware:

from last_seen.model import LastSeen

# save with a special module
LastSeen.object.when(user=user, module='forum')

Middleware

The provided middleware keeps track of when an authenticated user has been last seen on the site,

If you want to keep track of a user last seen on a part of a site, you can use a special module name and use:

from last_seen.model import LastSeen

# save with a special module
LastSeen.object.when(user=user, module='forum')

Then to get the data:

from last_seen.model import LastSeen

# user last seen on any part of the site
seen = LastSeen.object.when(user=user)

# user last seen on a module
seen = LastSeen.object.when(user=user, module='forum')

Settings

LAST_SEEN_DEFAULT_MODULE
The default module used on the middleware. The default value is default.
LAST_SEEN_INTERVAL
How often is the last seen timestamp updated to the database. The default is 2 hours.

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.