Package: django-currentuser
Conveniently store reference to request user on thread/db level.QuickstartDifferences to django-cuserSupported VersionsRelease NotesContributingReporting issues/improvementsPull RequestsSetting up all Python versionsCode of ConductContributorsQuickstartInstall django-currentuser:pip install django-currentuserAdd 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)

# As model field:
from django_currentuser.db.models import CurrentUserField
class Foo(models.Model):
    created_by = CurrentUserField()
    updated_by = CurrentUserField(on_update=True)Differences to django-cuserBoth libraries serve the same purpose, but be aware of these
differences (as of django-cuser v.2017.3.16):django-currentuser’s CurrentUserField stores the reference to the request user
at initialization of the model instance and still allows you to overwrite the
value before saving. django-cuser sets the value in the pre_save handler
of the field just before writing it to the database. Intermediate changes
will be ignored.django-cuser deletes the user reference from the thread after finishing a
response and it will therefore no longer be available for testing purposes.Supported Versionsfor django-currentuser`, fixes are always made against the latest versionfor Python, support is guided byhttps://devguide.python.org/versions/#supported-versionsfor Django, support is guided byhttps://docs.djangoproject.com/en/dev/faq/install/#what-python-version-can-i-use-with-djangoandhttps://www.djangoproject.com/download/#supported-versions(assuming the Python version
listed there is supported)Release Notes0.7.0
* add support for Django 5.0
* add support for Python 3.12
* drop support for Django 4.0 and 4.10.6.1remove project transfer warning from README in order not to scare people away from the project0.6.0add support for Django 4.0, 4.1, and 4.2add support for Python 3.11drop support for Python 3.6 and 3.70.5.3 - add support for Django 3.2 and Python 3.90.5.2 - Fixed Django deprecation warning about usingugettext_lazy()0.5.1 - add support for Django 3.1 and Python 3.80.5.0
- add support for update on save (thank you @felubra)
- no longer build on Python 3.5, deprecated0.4.3 - add support for Django 3.00.4.2 - Minor fix for supported Django and Python versions0.4.0 - update supported versionsdrop support for Python 3.4drop support for Django 2.0add support for Python 3.7add support for Django 2.2update tox3travis.py to not loose deployment feature0.3.4 - Use public Travis for packaging to remove dependency on outdated build
system0.3.3 - drop Python 3.7 support due to build process problems0.3.1 - attempt to add Python 3.7 support0.3.0 - update supported versions according tohttps://www.djangoproject.com/download/#supported-versionsandhttps://devguide.python.org/#status-of-python-branchesdrop support for Python 3.20.2.3 - support custom user model, drop Django 1.10 support0.2.2 - support Django 2.00.2.1 - version fixes #9support Django 1.11.x and not just 1.11.00.2.0 - New middleclass formatAdapt to new object based middle class format of Django 1.10+Drop support for deprecated Django versions 1.8 and 1.90.1.1 - minor releasesuppress warning for passed kwargs as long as they match the defaults (avoids them being printed during running tests when fields are cloned)0.1.0 - initial releaseprovides middleware + methods to set + retrieve reference of currently logged in user from threadprovides CurrentUserField that by default stores the currently logged in usersupports Django 1.10, 1.11 on python 2.7, 3.4, 3.5, and 3.6 - as per theofficial django docsContributingAs an open source project, we welcome contributions.The code lives ongithub.Reporting issues/improvementsPlease open anissue on githubor provide apull requestwhether for code or for the documentation.For non-trivial changes, we kindly ask you to open an issue, as it might be rejected.
However, if the diff of a pull request better illustrates the point, feel free to make
it a pull request anyway.Pull Requestsfor code changesit must have tests covering the change. You might be asked to cover missing scenariosthe latestflake8will be run and shouldn’t produce any warningif the change is significant enough, documentation has to be providedTo trigger the packaging, runmake releaseon the master branch with a changed
version number.Setting up all Python versionssudo apt-get -y install software-properties-common
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
for version in 3.8 3.9 3.10 3.11; do
  py=python$version
  sudo apt-get -y install ${py} ${py}-dev
doneCode of ConductAs it is a Django extension, it followsDjango’s own Code of Conduct.
As there is no mailing list yet, please usegithub issuesContributorsCurrent maintainer: @zsoldosp
Initial development & maintenance: @PaesslerAGFor contributors, seegithub contributors.