DBCA Django utility classes and functions.
- Python 3.12 or later
- Django 5.2 or later
Dependencies for this project are managed using uv. With uv installed, change into the project directory and run:
uv sync
Activate the virtualenv like so:
source .venv/bin/activate
Run unit tests using pytest (or tox, to test against multiple Python versions):
pytest -sv
tox -v
Tagged releases are built and pushed to PyPI automatically using a GitHub
workflow in the project. Update the project version in pyproject.toml and
tag the required commit with the same value to trigger a release. Packages
can also be built and uploaded manually to PyPI using uv,
if required:
uv build
uv publish
- Install via uv/pip/etc.:
pip install dbca-utils
This will automatically login and create users using headers from an upstream proxy (REMOTE_USER and some others). The logout view will redirect to a separate logout page which clears the SSO session.
Add dbca_utils.middleware.SSOLoginMiddleware to settings.MIDDLEWARE (after both of
django.contrib.sessions.middleware.SessionMiddleware and
django.contrib.auth.middleware.AuthenticationMiddleware.
Ensure that AUTHENTICATION_BACKENDS contains django.contrib.auth.backends.ModelBackend,
as this middleware depends on it for retrieving the logged in user for a session.
Note that the middleware will still work without it, but will reauthenticate the session
on every request, and request.user.is_authenticated won't work properly/will be false.
Example:
MIDDLEWARE = [
...,
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'dbca_utils.middleware.SSOLoginMiddleware'
...,
]AuditMixin is an extension of Django.db.model.Model that adds a number of additional fields:
creator- FK toAUTH_USER_MODEL, used to record the object creatormodifier- FK toAUTH_USER_MODEL, used to record who the object was last modified bycreated- a timestamp that is set on initial object savemodified- an auto-updating timestamp (on each object save)