Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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
Comment

models. type for phone number in django

from django.core.validators import RegexValidator

class Person(models.Model):
    phoneNumberRegex = RegexValidator(regex = r"^+?1?d{8,15}$")
    phoneNumber = models.CharField(validators = [phoneNumberRegex], max_length = 16, unique = True)
Comment

PREVIOUS NEXT
Code Example
Python :: string to bits python 
Python :: how to detect when a key is pressed in pygame 
Python :: how to round in python 
Python :: django login view 
Python :: randint python 
Python :: python how to make notepad 
Python :: pip in vscode linux 
Python :: send telegram bot message python 
Python :: Date Time split in python 
Python :: how to check if a list is nested or not 
Python :: python slicing multi dimensional array 
Python :: count number of each item in list python 
Python :: python define an array of dictonary 
Python :: check remote port is open or not using python 
Python :: basic games to code in python 
Python :: count characters in string python 
Python :: python convert multidimensional array to one dimensional 
Python :: pick a random number from a list in python 
Python :: create app in django 
Python :: 3d array python numpy 
Python :: binary, decimal, hex conversion python 
Python :: add one row to dataframe 
Python :: how yo import python lib 
Python :: how to count number of columns in dataframe python 
Python :: how to use cv2.COLOR_BGR2GRAY 
Python :: remove keys from array python 
Python :: multiple boxplots python 
Python :: import file from parent directory python 
Python :: pandas groupby mean round 
Python :: django pandas queryset 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =