Giter Club home page Giter Club logo

django-last-seen's Introduction

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.

django-last-seen's People

Contributors

generalov avatar kdahlhaus avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

generalov skynv zagi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.