zsoldosp / django-currentuser

Conveniently store reference to request user on thread/db level.
BSD 3-Clause "New" or "Revised" License
141 stars 40 forks source link
django pip threads user

============================= django-currentuser

.. contents:: Conveniently store reference to request user on thread/db level.

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)

# 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-cuser

Both libraries serve the same purpose, but be aware of these differences (as of django-cuser v.2017.3.16):

Supported Versions

Release Notes

.. contributing start

Contributing

As an open source project, we welcome contributions.

The code lives on github <https://github.com/zsoldosp/django-currentuser>_.

Reporting issues/improvements


Please open an `issue on github <https://github.com/zsoldosp/django-currentuser/issues/>`_
or provide a `pull request <https://github.com/zsoldosp/django-currentuser/pulls/>`_
whether 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 Requests

To trigger the packaging, run make release on the master branch with a changed version number.

Setting up all Python versions


::

    sudo 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
    done

Code of Conduct

As it is a Django extension, it follows Django's own Code of Conduct <https://www.djangoproject.com/conduct/>. As there is no mailing list yet, please use github issues

Contributors


Current maintainer: @zsoldosp
Initial development & maintenance: @PaesslerAG

For contributors, see `github contributors`_.

.. contributing end

.. _github contributors: https://github.com/zsoldosp/django-currentuser/graphs/contributors
.. _github issues: https://github.com/zsoldosp/django-currentuser/issues