forked from aaronn/django-rest-framework-passwordless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
23 lines (16 loc) · 861 Bytes
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from django.contrib.auth.models import AbstractBaseUser
from django.contrib.auth.models import BaseUserManager
from django.core.validators import RegexValidator
from django.db import models
phone_regex = RegexValidator(regex=r'^\+[1-9]\d{1,14}$',
message="Mobile number must be entered in the format:"
" '+999999999'. Up to 15 digits allowed.")
class CustomUser(AbstractBaseUser):
email = models.EmailField(max_length=255, unique=True, blank=True, null=True)
email_verified = models.BooleanField(default=False)
mobile = models.CharField(validators=[phone_regex], max_length=17, unique=True, blank=True, null=True)
mobile_verified = models.BooleanField(default=False)
objects = BaseUserManager()
USERNAME_FIELD = 'email'
class Meta:
app_label = 'tests'