django-two-factor-auth
Complete Two-Factor Authentication for Django
Decision gist · record as of 2026-08-14
Yes. This is a mature, actively maintained package (1876 GitHub stars, recent commits) with no known vulnerabilities, low install friction, and permissive licensing. It solves a critical security problem for Django projects and integrates cleanly with Django's built-in auth framework. Use it when you need production-grade 2FA for a Django application.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Django 4.2+ and Python 3.9+.
- Depends on django-otp, qrcode, django-phonenumber-field, and django-formtools as runtime dependencies.
- Low friction installation with a pure-Python wheel.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.
last release 2025-09-27 (321 days) · last repo commit 2026-08-10 · 1,876 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 3,111,562 downloads/mo, #2,750 on PyPI
Alternatives
Verify before relying
pip install django-two-factor-auth
from django_otp.plugins.otp_totp.models import StaticDevice
from django_two_factor_auth.views import LoginView
# Add to Django settings.INSTALLED_APPS:
# 'django_otp',
# 'django_two_factor_auth',- Whether Twilio SMS integration is fully functional or requires additional setup beyond the package itself.
- Performance characteristics when handling high volumes of authentication requests.
What it is and what it does
Django Two-Factor Authentication is a complete 2FA solution built on top of Django's authentication framework and the django-otp one-time password library. It integrates seamlessly into existing Django projects and lets users authenticate through multiple channels: one-time passwords (TOTP), SMS text messages, voice calls, token generator apps like Google Authenticator, or hardware tokens such as YubiKey.
The package handles the full authentication flow, from user enrollment through verification, and is designed to mirror the user experience of Google's Two-Step Authentication. It includes support for multiple languages and works with Django 4.2 through 5.1 on Python 3.9–3.13. An example app is available for testing most features, and documentation is comprehensive.
Use it for
- Add SMS or call-based 2FA to a Django web application for user account security.
- Integrate TOTP-based authentication (Google Authenticator, Authy) into an existing Django login flow.
- Support hardware security keys (YubiKey) for high-security user accounts.
- Build a multi-channel authentication system where users choose their preferred 2FA method.
- Enhance Django admin or staff portals with mandatory two-factor verification.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
This is a mature, actively maintained package (1876 GitHub stars, recent commits) with no known vulnerabilities, low install friction, and permissive licensing. It solves a critical security problem for Django projects and integrates cleanly with Django's built-in auth framework. Use it when you need production-grade 2FA for a Django application.
Install
django-two-factor-auth on PyPI
Before you install
Low friction installation with a pure-Python wheel. Active maintenance with recent commits and no known vulnerabilities. Supports current Django versions (4.2, 5.0, 5.1, 5.2) and Python 3.9–3.13.
Requires Django 4.2+ and Python 3.9+. Depends on django-otp, qrcode, django-phonenumber-field, and django-formtools as runtime dependencies.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install django-two-factor-auth
from django_otp.plugins.otp_totp.models import StaticDevice
from django_two_factor_auth.views import LoginView
# Add to Django settings.INSTALLED_APPS:
# 'django_otp',
# 'django_two_factor_auth',
Verify before relying
- Whether Twilio SMS integration is fully functional or requires additional setup beyond the package itself.
- Performance characteristics when handling high volumes of authentication requests.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 5 packagesDjangodjango_otpqrcodedjango-phonenumber-fielddjango-formtools |
| Maintenance | Actively maintained 321 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,111,562 / month, #2,750 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.0Framework :: Django :: 5.1Framework :: Django :: 5.2Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: SecurityTopic :: System :: Systems Administration :: Authentication/Directory |
Evidence: django_two_factor_auth-1.18.1-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “2fa for django”
- django-two-factor-authAdds complete two-factor authentication to Django projects,…
- django-allauth-2faAdds two-factor authentication to django-allauth versions older than…
- django-otpAdds one-time password (OTP) support to Django applications, enabling…
Give your agent the search over MCP, or paste the wish link into any chat.
More Security packages
Provides Python bindings to the FreeDesktop.org Secret Service API for securely storing and retrieving passwords and secrets through GNOME Keyring, KWallet, or KeePassXC.
MSAL for Python handles OAuth2 and OpenID Connect authentication with Microsoft identity services, managing token acquisition, caching, and refresh for applications integrating with Microsoft Entra ID, Microsoft Accounts, and Azure AD B2C.
joserfc implements JOSE standards (JWS, JWE, JWK, JWT, and related RFCs) for signing, encrypting, and managing JSON-based cryptographic tokens in Python.
Authlib provides a complete implementation of OAuth 1.0, OAuth 2.0, and OpenID Connect 1.0 for building both authentication clients and servers, with built-in support for JWS, JWK, JWA, and JWT standards.
Provides low-level CFFI bindings to the official Argon2 password hashing algorithm for use by libraries and applications that need direct access to Argon2 without higher-level abstractions.
ADAL for Python authenticates applications with Azure Active Directory to obtain tokens for accessing Azure AD-protected resources.
Install only if maintaining existing code that already depends on it, and plan a migration.
See also authy · django-otp · django-allauth-2fa · yubico-client · PyOTP · django-user-sessions · google-reauth · django-otp-webauthn · oathtool · vonage-verify-legacy