Answers for "how to add phone number model in django"

2

Django Phone Number Field

from django.core.validators import RegexValidator

class PhoneModel(models.Model):
    ...
    phone_regex = RegexValidator(regex=r'^+?1?d{9,15}$', message="Phone number must be entered in the format: '+999999999'. Up to 15 digits allowed.")
    phone_number = models.CharField(validators=[phone_regex], max_length=17, blank=True) # validators should be a list
Posted by: Guest on July-06-2021
0

how to add phone number to django user model

class ExtendedUserExample(models.Model):
    user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    created = models.DateTimeField(auto_now_add=True)
    phone_number = models.IntegerField(blank=True)
Posted by: Guest on November-16-2020

Code answers related to "how to add phone number model in django"

Browse Popular Code Answers by Language