Allow user to login and register with email address.
NOTICE: We are currently in the development stage. If you use this library, please upgrade to the latest version. Issues are welcome.
You can view the documentation here.
- Integration Guide - How to integrate into your Django project
- API Reference - Complete API documentation with stability guarantees
- Configuration Guide - All configuration options explained
- Extension Points - How to customize and extend functionality
- Compatibility Matrix - Supported Python, Django, and database versions
- Security Policy - Security features and best practices
pip install django-login-email
List of the urls for exmaple project:
/homefor protected url./account/loginfor login./account/logoutfor logout./account/verifyfor email verify.
- The developer could define their own
Usermodel. - Time-limited of login link.
- limited of sending email. Using TimeLimt to set minutes.
- The link could be used for Login once.
- Register new user.
- Support multiple user.
- Ban the IP to send mail frequently without login.
- Support django-templated-email
- Support Django Anymail
- Allow users to change their email address.
- Enable 2FA.
- More easier and customizable login link.
- add
django_login_emailto your appsettings.py.
INSTALLED_APP = [
...,
'django_login_email',
...
]- Implement the LoginView, for example, like this:
from django.shortcuts import render
from django.urls import reverse
from django_login_email import email as e
from django_login_email import views as v
# Create your views here.
loginInfo, registerInfo = e.get_info_class("meterhub")
class LoginView(v.EmailLoginView):
login_info_class = loginInfo
register_info_class = registerInfo
class VerifyView(v.EmailVerifyView):
def get_success_url(self):
return reverse("home")
class LogoutView(v.EmailLogoutView):
pass
- set the view in your
urls.py.
from django.contrib import admin
from django.urls import path
from <yourapp> import views as v
from django_login_email.views import HomeView
urlpatterns = [
...,
path("account/login", v.LoginView.as_view(), name="login"),
path("account/verify", v.VerifyView.as_view(), name="verify"),
path("account/logout", v.LogoutView.as_view(), name="logout"),
path("", HomeView.as_view(), name="home"),
]That's all.
Debug the email with docker run -d --name mailhog -p 1025:1025 -p 8025:8025 mailhog/mailhog
For detailed configuration options, see the Configuration Reference.
Quick settings overview:
- Config
LoginView.tlto adjust rate limiting (default: 10 minutes between emails) - Configure email server settings in your Django
settings.py(see settings/settings.py for examples) - Customize email templates by subclassing
EmailLoginInfoandEmailRegisterInfo
Example - Disable rate limiting for development:
class YouLoginView(LoginView):
def check_could_send(self, email) -> bool:
# FOR DEBUG
return True- Python: 3.10+ (tested: 3.10, 3.11, 3.12)
- Django: 5.0.4+ (tested: 5.0.x)
- Databases: SQLite, PostgreSQL, MySQL/MariaDB
See COMPATIBILITY.md for detailed version support.
This package implements passwordless authentication with the following security features:
- ✅ AES-encrypted tokens
- ✅ Time-limited tokens (default: 10 minutes)
- ✅ One-time use tokens
- ✅ Rate limiting
- ✅ IP banning for abuse prevention
See SECURITY.md for security policy and best practices.
- Academically prove the safety of this method.