---
title: "Discussion on \"An activity log for Django that knows who really clicked, even under impersonation\" | Hashnode"
description: "Discussion on \"An activity log for Django that knows who really clicked, even under impersonation\". Building a Django activity log that records the real user under impersonation, works from Celery and websockets, dedupes views and stays readable."
url: "https://hashnode.com/posts/an-activity-log-for-django-that-knows-who-really-clicked-even-under-impersonation/6aff5711e430f2cfe731e7db"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [An activity log for Django that knows who really clicked, even under impersonation](https://mahmadmanzoor.hashnode.dev/an-activity-log-for-django-that-knows-who-really-clicked-even-under-impersonation?utm_source=hashnode&utm_medium=feed)

Building a Django activity log that records the real user under impersonation, works from Celery and websockets, dedupes views and stays readable.

6d ago · 10 min read · mahmadmanzoor.hashnode.dev  
Read the article

-   [#django](https://hashnode.com/tag/django)
-   [#python](https://hashnode.com/tag/python)
-   [#security](https://hashnode.com/tag/security)
-   [#celery](https://hashnode.com/tag/celery)
-   [#webdev](https://hashnode.com/tag/webdev)

## Written by

[Muhammad Ahmad](https://hashnode.com/@mahmadmanzoor)

@mahmadmanzoor · Lahore, Pakistan

  
[View profile](https://hashnode.com/@mahmadmanzoor)

AI Product Engineer @ RipeSeed. Shipping LLM features, agents and evals in production.

## Responses 1

Markdown supported · ⌘↵ to post

[AI Developer](https://hashnode.com/@lycore)

[1h ago](https://hashnode.com/posts/an-activity-log-for-django-that-knows-who-really-clicked-even-under-impersonation/6aff5711e430f2cfe731e7db/comment/6b084f65664bb94124202854)

The safe\_log wrappers that swallow exceptions protect the request, but they also make audit gaps silent. A counter metric for failed activity writes (with an alert on any sustained rate) would make that visible, and a Celery retry or small outbox table could cover the cases that matter, like impersonated destructive actions. On the dedupe, has\_recent\_content\_action is a read-then-write, so two concurrent requests can both pass; cache.add() with a key of user, action and object gives an atomic once-per-window check. Last, since original\_user\_id rides in the JWT, it's worth re-validating server-side that the original user still has the impersonation permission when each row is written.
