Skip to main content

A Django application that provides a custom User model where the username is the email address.

Project description

Django Rapyd ModernAuth

PyPI version Python versions License CI

A small Django pluggable app that provides a custom User model where the email address is the username. No username field, no extra settings, no migrations beyond the initial one.

Inspiration

Users today expect to use their email address as the username during authentication. This works well because:

  • Users already know their email addresses by heart.
  • Since email addresses are unique, users don't need to remember yet another item when either signing up or logging into web applications. IMHO this is a significant factor that plays a vital role in user adoption.
  • This is a time tested model and many web applications today follow this.

However, Django's default approach for authentication requires a user provide both a username and an email address during sign up and then just use the username during login.

Requirements

  • Python 3.10, 3.11, 3.12, or 3.13
  • Django 4.2 LTS or Django 5.2 LTS

Installation

Important: swap in this user model before running migrate for the first time. Switching AUTH_USER_MODEL mid-project requires hand-written data migrations across every foreign key to the user model. See Django's docs on substituting a custom user model.

Install the package:

pip install django-rapyd-modernauth

Add modernauth to INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    "modernauth",
]

Point Django at the custom user model in settings.py:

AUTH_USER_MODEL = "modernauth.User"

Create the database tables:

python manage.py migrate

Usage

The custom User model behaves like Django's default AbstractUser with one difference: email is the unique identifier and there is no username field. Use get_user_model() rather than importing the model directly so your code keeps working if AUTH_USER_MODEL is ever swapped again.

from django.contrib.auth import get_user_model

User = get_user_model()

User.objects.create_user(email="alice@example.com", password="…")
User.objects.create_superuser(email="root@example.com", password="…")

The admin's createsuperuser command will prompt for an email instead of a username:

python manage.py createsuperuser

Login forms, the admin, and authenticate() all use email as the credential.

Contributing

Pull requests are welcome — the project is intentionally small, so bug fixes, test improvements, and Django LTS support updates are the most likely to land. See CONTRIBUTING.md for the full development setup, test workflow, and release process.

For security vulnerabilities, see SECURITY.md for the private disclosure process. Do not file a public issue for security bugs.

License

Apache License 2.0 — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_rapyd_modernauth-0.0.7.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_rapyd_modernauth-0.0.7-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file django_rapyd_modernauth-0.0.7.tar.gz.

File metadata

  • Download URL: django_rapyd_modernauth-0.0.7.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_rapyd_modernauth-0.0.7.tar.gz
Algorithm Hash digest
SHA256 0ba189f4ce2fe23bf1e13325de230d627313b9ad127445878043eabac7fabbf1
MD5 1ce77123db29257dec22aa57174aaf5d
BLAKE2b-256 14993b5686de89c810e374b5d17b8aa9cf141d7af0df30b330c3bd2117bec219

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_rapyd_modernauth-0.0.7.tar.gz:

Publisher: publish.yml on karthicraghupathi/django_rapyd_modernauth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_rapyd_modernauth-0.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for django_rapyd_modernauth-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ca3bd232eb53bb8c3d22a52b65f8860fe7ca1bbe7688eef6b077085942673bd7
MD5 d0b4002d9e54fb473230b15de3e66e88
BLAKE2b-256 6a71a5a004b191edca1d37fa0dee78fef0fa398d3599dbc3585151c8ef698969

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_rapyd_modernauth-0.0.7-py3-none-any.whl:

Publisher: publish.yml on karthicraghupathi/django_rapyd_modernauth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page