Metadata-Version: 2.4
Name: django-mz-users
Version: 0.1.0a2
Summary: Custom user model and user management for Django projects of the django-mz family
Keywords: django,users,user-model,auth,accounts,allauth
Author: Miroslav Zvolský
Author-email: Miroslav Zvolský <zvolsky@seznam.cz>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Django
Classifier: Framework :: Django :: 5.2
Classifier: Framework :: Django :: 6.0
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Requires-Dist: django>=5.2
Requires-Dist: django-allauth[socialaccount]>=65.0 ; extra == 'allauth'
Requires-Python: >=3.12
Provides-Extra: allauth
Description-Content-Type: text/markdown

# django-mz-users

The user model and user management for Django projects of the **django-mz** family (projects whose admin drives
an API and a Vue frontend). It is a small, plain Django app that any project can use.

> Status: alpha (0.1.0a2). The API may change before 1.0.

## Why a custom user model from the start

Django recommends a custom user model for every new project: switching `AUTH_USER_MODEL` later, on a live
database, is hard. `mz_users.User` is Django's standard user (`AbstractUser`) in its own app, so projects can share
it and extend it later without that switch.

## Installation

```console
pip install django-mz-users
```

```python
INSTALLED_APPS = [..., 'django.contrib.auth', 'mz_users', ...]
AUTH_USER_MODEL = 'mz_users.User'
```

Set it before the first `migrate` of the project. The app label is `mz_users` (table `mz_users_user`).

## What is included

- `mz_users.User` – the user model (`AbstractUser`), Czech labels included
- admin registration with Django's `UserAdmin`: the new-user form asks for the password twice

- optional integration with django-allauth (`mz_users.accounts`), see below

Self-registration, e-mail verification, password reset and social login are django-allauth's job (its headless API
works with this model as is).

## With django-allauth

```console
pip install django-mz-users[allauth]
```

With mandatory e-mail verification (`ACCOUNT_EMAIL_VERIFICATION = 'mandatory'`) allauth lets in only users with a
verified e-mail. Users created outside allauth (the admin, `createsuperuser`, commands, scripts) are trusted: with
the adapters below their e-mail becomes a verified primary address whenever they are saved. Sign-ups and provider
logins still verify their address through allauth.

```python
ACCOUNT_ADAPTER = 'mz_users.accounts.AccountAdapter'
SOCIALACCOUNT_ADAPTER = 'mz_users.accounts.SocialAccountAdapter'  # with allauth.socialaccount
```

The adapters mark the users allauth creates; without them nothing is verified automatically (that would let
sign-ups skip verification). Subclass them for your own adapters. A project that adopts allauth with existing
users verifies their e-mails once:

```console
python manage.py mz_users_verify_emails
```

## Development

```console
uv run --package django-mz-users pytest
```

## License

MIT
