# Realtime Django admin: who’s online, edit locks and live change lists

> One app in INSTALLED_APPS and one middleware make the Django admin multiplayer: see who else is online and on the same page, lock a record while one person edits it, and watch change lists update themselves. Works with the stock admin and django-unfold, with no template changes.

Source: https://hibira.io/guides/django-admin

One app in INSTALLED_APPS and one middleware make the Django admin multiplayer: see who else is online and on the same page, lock a record while one person edits it, and watch change lists update themselves. Works with the stock admin and django-unfold, with no template changes.

Package: django-hibira

- Who’s online next to the user menu, and avatars of everyone else on the same page.
- Edit locks: the first person on a change form edits it, and everyone else sees who and can’t save over them until they leave. No lock table and no polling.
- Change lists refresh in place when rows are added, saved or deleted anywhere (the admin, an API, a Celery task or the shell), and a change form says when its record was saved elsewhere.
- notify(user, "...") shows a toast on every admin page that user has open. Django 4.2 to 6.1, with the stock admin or django-unfold.

## 1. Install

```shell
pip install "django-hibira>=0.5"

HIBIRA_APP_ID=YOUR_APP_ID
HIBIRA_APP_KEY=YOUR_APP_KEY
HIBIRA_APP_SECRET=YOUR_APP_SECRET
HIBIRA_HOST=ws.hibira.io

python manage.py hibira_check
```

## 2. Set it up

```python
# settings.py
INSTALLED_APPS = [
    # ...
    "django.contrib.admin",
    "django_hibira",
    "django_hibira.live_admin",
]

MIDDLEWARE = [
    # ...
    "django.contrib.auth.middleware.AuthenticationMiddleware",
    "django_hibira.live_admin.middleware.LiveAdminMiddleware",
]

# urls.py
urlpatterns += [path("hibira/", include("django_hibira.urls"))]
```

## 3. Use it

```python
from django_hibira.live_admin import changed, notify

# A toast on every admin page the user has open
notify(order.assignee, f"Order {order.number} was paid", title="Orders",
       level="success", url=f"/admin/shop/order/{order.pk}/change/")

# Bulk updates send no signals: refresh open change lists yourself
Order.objects.filter(status="new").update(status="paid")
changed(Order)
```

## Before you start

- The app secret is shown only once, when you create the app or rotate its secret. Keep it on your server, never in a browser or game build.
- On the Free plan, list every origin your pages load from in the app’s allowed origins (http://localhost:8000 while developing, then your domain). "*" needs a paid plan.
- Each open admin tab is one connection, so the Free plan’s 100 connections cover most admin teams.
- Bulk changes such as QuerySet.update() send no model signals: call changed(Model) afterwards so open change lists refresh.

## Frequently asked questions

### Does it work with django-unfold?

Yes. The middleware adds its scripts to every admin page instead of overriding templates, so the stock admin, django-unfold and most admin themes work unchanged.

### Do I need Django Channels or Redis?

No. Your app stays a normal WSGI app: browsers connect to Hibira, and saves are sent to it after the transaction commits.

- [PyPI](https://pypi.org/project/django-hibira/)
- [GitHub](https://github.com/hibira-io/django)
