Skip to main content

Keep track of when a user has been last seen

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-last-seen-0.3.tar.gz (5.5 kB view details)

Uploaded Source

File details

Details for the file django-last-seen-0.3.tar.gz.

File metadata

File hashes

Hashes for django-last-seen-0.3.tar.gz
Algorithm Hash digest
SHA256 6f787451bff3b92e6f123b578f011cb68daee9f3f682aa82b4b26479bf8674b4
MD5 ab7bbc483520d81331810162f18adcf4
BLAKE2b-256 8bcf31729426d2d0926a71a3dc444083aa90019a4f9aa8cd6209ffec26970134

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page