django-otp is a pluggable framework designed to integrate two-factor authentication (2FA) into Django projects using one-time passwords (OTPs). It provides the core framework and common OTP algorithms (HOTP, TOTP), allowing developers to build custom 2FA solutions or leverage existing plugins. The current version is 1.7.0, and the project maintains a healthy release cadence with active maintenance.
pip install django-otpVerified import paths — ran on the pinned version, not inferred.
This quickstart outlines the essential steps to integrate `django-otp` into a Django project. It involves adding `django_otp` and at least one OTP plugin (e.g., `otp_totp`) to `INSTALLED_APPS` and enabling `OTPMiddleware`. For admin site integration, assign `OTPAdminSite` to `admin.site.__class__`. Remember to run `python manage.py migrate` after updating `INSTALLED_APPS` to create necessary database tables.
Upgrade your Python and Django versions to meet the minimum requirements of the `django-otp` version you intend to use (e.g., Python >=3.8 for 1.7.0).
Add `'django_otp.middleware.OTPMiddleware'` to your `MIDDLEWARE` list in `settings.py`, ensuring it is placed after `'django.contrib.auth.middleware.AuthenticationMiddleware'`.
Understand `django-otp`'s role as a foundational framework. If you need a complete 2FA application with ready-made UI and flows, consider `django-two-factor-auth`, which builds upon `django-otp`.
Install `qrcode` or `segno` using pip: `pip install qrcode` or `pip install segno`.