Skip to main content

A lightweight Django Admin plugin showing who’s logged in from where using the cache. Supports Telize, django-ipware, user-agents and GeoIP

Requirements

Optional

Installation

  • Make sure you have Django’s Cache backend set up.

  • Install using pip: pip install django-whoshere

  • Add django_whoshere to INSTALLED_APPS in settings.py:

    INSTALLED_APPS = (
        # other apps
        'django_whoshere',
    )
  • Add django_whoshere.middelware.TrackMiddleware to your MIDDLEWARE_CLASSES. Make sure it comes after your Authentication middleware.

MIDDLEWARE_CLASSES = (
    # other middleware
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django_whoshere.middleware.TrackMiddleware',
   # more middleware
)

Optional

Configuration

No configuration is needed but these settings are provided for convenience:

  • WHOSHERE_TIMEOUT = 300 Sets the timeout for user activity. Defaults to 300 seconds.

  • WHOSHERE_LABEL = 'Active Users' Overrides the admin link label. Defaults to ‘Active Users’

  • WHOSHERE_PREFIX = 'whoshere' Prefix used in cache keys. Defaults to ‘whoshere’.

  • WHOSHERE_TELIZE = True You can set this to ‘False’ to turn off geolocation lookups with Telize. Is always off if GeoIp is installed.

Template tags

Besides the admin interface, WhosHere’s functions are also available as template tags:

{% load whoshere %}

There are now {% active_user_count %} users logged in.

{% active_users as users %}
<ul>
{% for user in users %}
   <li>{{ user.username }} ({{ user.email }})</li>
{% endfor %}
</ul>

<p>Your IP address is {% your_ip %}</p>
<p>Your browser and platform is {% your_agent %}</p>
<p>You live in {% your_city %}, {% your_country %}</p>

Geolocation

Originally this plugin started with GeoIP support only, but this means you have to install the rather large database that it comes with. Not a problem if you already use it for other things, but not a lightweight solution if you only use it for WhosHere. As an alternative WhosHere uses the free Telize API over HTTPS by default to find the location of your logged in users. This comes with some caveats:

  • The Telize API is opensource, but you are sending users IP addresses, albeit anonymously, to a third party.

  • Being a free API it can sometimes be unavailable or slow

  • Your server needs HTTPS access to a remote location

You can turn off Telize lookups with WHOSHERE_TELIZE = False in your settings.py or by installing and configuring GeoIP.

Notes

  • Middleware is kept as small as possible and only adds IP and User Agent to the cache for the current logged in user.

  • No database tables are used. Instead WhosHere uses a proxy model of the User model.

  • Proxy models will create migrations but do not affect your database

  • Telize lookups are cached for performance

  • Using the excellent requests library for better SSL support

Todo

  • Add tests

  • Think of other things to add

Metadata

Release files for django-whoshere 0.1.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-whoshere 0.1.6.2
File Size Uploaded
django-whoshere-0.1.6.2.tar.gz 8.7 kB Details

Release files / django-whoshere-0.1.6.2.tar.gz

Download URL django-whoshere-0.1.6.2.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9d9587c29ecb9557776455bc2dcae3b5785927d1a045c7986026d876b13fc3fc
BLAKE2b-256 checksum
How to use checksums
97dc4d61ce6509ed9ed21aea2b03ce4006b5d711fa689ce9ded4349bc702176e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.6.2 This release

1 release file

0.1.6.1

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page