Conveniently store reference to request user on thread/db level.
Quickstart
Differences to django-cuser
Release Notes
Contributing
Reporting issues/improvements
Pull Requests
Setting up all Python versions
Code of Conduct
Quickstart
Install django-currentuser:
pip install django-currentuser
Add it to the middleware classes in your settings.py:
MIDDLEWARE = (
...,
django_currentuser.middleware.ThreadLocalUserMiddleware ,
)
Then use it in a project:
from django_currentuser.middleware import (
get_current_user, get_current_authenticated_user)
from django_currentuser.db.models import CurrentUserField
class Foo(models.Model):
created_by = CurrentUserField()
updated_by = CurrentUserField(on_update=True)
Differences to django-cuser
Both libraries serve the same purpose, but be aware of these
differences (as of django-cuser v.2017.3.16):
django-currentusers CurrentUserField stores the reference to the request user
at initialization of the mod
|