django-usermgmt
A production-oriented command line toolkit for managing users, groups and permissions in any Django project.
Stock manage.py only ships createsuperuser and changepassword. There is no built-in way to create a regular
user, list users, inspect permissions, manage groups or import accounts in bulk. django-usermgmt adds a single
management command, usermgr, that covers all of that, with safety guards, audit logging and scriptable output.
python manage.py usermgr create-user john --email john@example.com --group editors --create-missing-groups
python manage.py usermgr list-users --active --format json
python manage.py usermgr who-can blog.add_post
Highlights
- 26 actions across users, permissions, groups and bulk import/export.
- Custom user model support: the login field is read from
USERNAME_FIELD; extra fields via--field KEY=VALUE. - Safe password handling: interactive prompt, stdin or environment variable; validated against
AUTH_PASSWORD_VALIDATORS; never logged. - Safety guards: the last active superuser cannot be deleted, deactivated or demoted without
--force; destructive actions ask for confirmation. - Atomic and auditable: every mutation runs in a transaction and writes a line to the
usermgmt.auditlogger. - Automation friendly:
table,jsonandcsvoutput, stable exit codes, no prompts when stdin is not a TTY. - Layered design: all logic lives in
usermgmt.services; the command is a thin CLI wrapper you can bypass.
Requirements
| Component | Version |
|---|---|
| Python | 3.9 or newer |
| Django | 4.2 or newer |
No third-party dependencies.
Installation
-
pip install django-usermgmtor Copy theusermgmt/directory into your project, next tomanage.py. -
Add it to
INSTALLED_APPS:INSTALLED_APPS = [ # ... "django.contrib.auth", "django.contrib.contenttypes", "usermgmt", ]
-
Verify:
python manage.py usermgr -h
See examples/settings_snippet.py for an audit-log configuration.
Quick tour
# Create users
python manage.py usermgr create-user john --email john@example.com # prompts for a password
echo "$PW" | python manage.py usermgr create-user sari --password-stdin
python manage.py usermgr create-user svc-sso --no-password # unusable password (SSO / API only)
python manage.py usermgr create-user ops --staff --group operators --create-missing-groups
# Inspect
python manage.py usermgr list-users --active --stale-days 90 --format csv
python manage.py usermgr show-user john --all-perms
python manage.py usermgr check-user john --perm auth.view_user
# Permissions and groups
python manage.py usermgr create-group editors --perm blog.add_post --perm blog.change_post
python manage.py usermgr add-to-group john editors
python manage.py usermgr grant-perm john "reports.*"
python manage.py usermgr who-can blog.add_post
# Lifecycle
python manage.py usermgr set-password john --revoke-sessions
python manage.py usermgr deactivate john --revoke-sessions
# Bulk
python manage.py usermgr import-users examples/users.csv --dry-run
python manage.py usermgr export-users --format csv --output users.csv
Action overview
mindmap
root((usermgr))
Users
create-user
list-users
show-user
check-user
update-user
set-password
set-flags
activate
deactivate
delete-user
revoke-sessions
Permissions
grant-perm
revoke-perm
list-perms
who-can
Groups
create-group
delete-group
rename-group
list-groups
show-group
group-grant
group-revoke
add-to-group
remove-from-group
Bulk
import-users
export-users
How it fits together
flowchart LR
Admin["Operator / script / CI"] -->|"manage.py usermgr ..."| CLI["usermgr command<br/>(argparse, output, prompts)"]
CLI --> SVC["usermgmt.services<br/>(business logic)"]
Py["Your Python code<br/>(Celery, shell, tests)"] --> SVC
SVC --> ORM["Django ORM<br/>auth.User / Group / Permission"]
SVC --> LOG["usermgmt.audit logger"]
ORM --> DB[("Database")]
Documentation
| Document | Purpose |
|---|---|
| User guide | Task-oriented walkthroughs and recipes |
| Command reference | Every action, argument, output and exit code |
| Architecture | Design, data model and flow diagrams |
| Security guide | Threat model, password handling, audit logging, hardening checklist |
| Developer guide | Using the service layer, extending the command, running tests |
| Troubleshooting | Common errors and fixes |
| Changelog | Release history |
Running the tests
python manage.py test usermgmt
Known limitations
- Operates on the default database connection only (no
--databaseoption yet). revoke-sessionssupports database-backed sessions (django.contrib.sessions) only.who-canevaluates permissions the way Django'sModelBackenddoes (superuser, direct, via group). Custom authentication backends with their own permission logic are not consulted.- Passwords in import files are plain text; protect and delete those files (see the security guide).
for cli's color, install pip install rchf
👤 Author
Metadata
Release files for django-usermgmt 1.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_usermgmt-1.0.7.tar.gz | 39.4 kB | With provenance | Details for django_usermgmt-1.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_usermgmt-1.0.7-py3-none-any.whl | Python 3 | none | any | Details for django_usermgmt-1.0.7-py3-none-any.whl |
Total release size: 61.5 kB
Release files / django_usermgmt-1.0.7.tar.gz
| Download URL | django_usermgmt-1.0.7.tar.gz |
|---|---|
| Size | 39.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0c51d1de3c618fc8e06ca9cb60155be635c0c90ca411375a2adc64188a67cc2e
|
|
BLAKE2b-256 checksum How to use checksums |
ecf174518e3d4f61a6d54b319ea53948a1f7e9c5f356179b89496486d0522c20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logRelease files / django_usermgmt-1.0.7-py3-none-any.whl
| Download URL | django_usermgmt-1.0.7-py3-none-any.whl |
|---|---|
| Size | 22.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c8527923977ecc839e213914283981c271560342c8a55fab4b96602bf034522
|
|
BLAKE2b-256 checksum How to use checksums |
77c9c5a16c776a9b7c51e32dea0ecabb8cc52c1195945957ce13b1470ad043c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logSecurity for django-usermgmt 1.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for django_usermgmt-1.0.7.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.