Skip to main content

A Django package to show online/offline status and last seen time.

Project description

Django User Status

A simple Django package to track and display a user's online/offline status and last seen time using Django's caching framework.

Installation

  1. Install the package: pip install django-user-status

  2. Add the middleware to your settings.py:

    MIDDLEWARE = [
        # ... other middleware
        'django_user_status.middleware.UserStatusMiddleware',
    ]
    

Load the template tags in your templates:

{% load user_status_tags %}

Configuration (Optional) You can customize the package's behavior by adding the following settings to your settings.py file.

  • USER_STATUS_CACHE_DURATION: The time in seconds that a user is considered "online" after their last request. Defaults to 300 (5 minutes).
  • USER_STATUS_CACHE_KEY_PREFIX: The prefix for the cache key. Useful to avoid key collisions. Defaults to 'last_seen'. Example settings.py:

Set the user to be "online" for 10 minutes

USER_STATUS_CACHE_DURATION = 600

Use a different cache key prefix

USER_STATUS_CACHE_KEY_PREFIX = 'user_activity'

Usage In your templates: To show a user's status:

{% get_user_status user %}

To show the last seen time:

{% get_last_seen user %}

What's New in Version 0.1.1

  • Bug Fix: Resolved a TypeError related to timezone-aware and naive datetimes. The package now correctly uses timezone-aware datetimes for all cache and status checks, ensuring reliability.

  • Added Unit Tests: Comprehensive unit tests have been added to ensure the reliability and correctness of the middleware and template tags.

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_user_status-0.1.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_user_status-0.1.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file django_user_status-0.1.1.tar.gz.

File metadata

  • Download URL: django_user_status-0.1.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for django_user_status-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9c46f95406a795791bfcdd5624a0b1026b9d1c3bf07b7c8143173dae150efae2
MD5 b81ab81581ed99d4adfa84b357291f99
BLAKE2b-256 dad6d8dd2ebc47cc44c483f8b79bd382889e97ee01089b262e5f384be776fa65

See more details on using hashes here.

File details

Details for the file django_user_status-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_user_status-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f645534413abe58cecef4da5d8f0ca8a1e913d40cbfb186f794574c242e9e76
MD5 82e27165bbe8ac5b5032eede887b2456
BLAKE2b-256 db4beee0f3f435d59f7b710eae4de6a67ba77c3df7bd2a716f6f5676c27c14e1

See more details on using hashes here.

Supported by

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