mirror of
https://github.com/django/django.git
synced 2024-11-29 06:03:25 +01:00
5ceaf14686
Thanks Ramin Farajpour Cami for the report.
25 lines
763 B
Python
25 lines
763 B
Python
from django.contrib.auth.base_user import AbstractBaseUser
|
|
from django.contrib.auth.models import BaseUserManager
|
|
from django.db import models
|
|
|
|
|
|
class CustomEmailFieldUserManager(BaseUserManager):
|
|
def create_user(self, username, password, email):
|
|
user = self.model(username=username)
|
|
user.set_password(password)
|
|
user.email_address = email
|
|
user.save(using=self._db)
|
|
return user
|
|
|
|
|
|
class CustomEmailField(AbstractBaseUser):
|
|
username = models.CharField(max_length=255)
|
|
password = models.CharField(max_length=255)
|
|
email_address = models.EmailField()
|
|
is_active = models.BooleanField(default=True)
|
|
|
|
EMAIL_FIELD = 'email_address'
|
|
USERNAME_FIELD = 'username'
|
|
|
|
objects = CustomEmailFieldUserManager()
|