1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00

Fixed #36087 -- Supported password reset on a custom user model with a composite primary key.

This commit is contained in:
Sarah Boyce
2025-01-13 12:01:49 +01:00
parent d83fb782d3
commit 23c6effac0
5 changed files with 37 additions and 4 deletions

View File

@@ -119,6 +119,19 @@ class CustomUserWithoutIsActiveField(AbstractBaseUser):
USERNAME_FIELD = "username"
class CustomUserCompositePrimaryKey(AbstractBaseUser):
pk = models.CompositePrimaryKey("email", "date_of_birth")
email = models.EmailField(verbose_name="email address", max_length=255, unique=True)
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)
date_of_birth = models.DateField()
custom_objects = CustomUserManager()
USERNAME_FIELD = "email"
REQUIRED_FIELDS = ["date_of_birth"]
# The extension user is a simple extension of the built-in user class,
# adding a required date_of_birth field. This allows us to check for
# any hard references to the name "User" in forms/handlers etc.