Answers for "how to import validators in django"

1

using regex validators in django models

from django.core.validators import RegexValidator
from django.db import models
PHONE_NUMBER_REGEX = RegexValidator(r'^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-s./0-9]*$', 'only valid email is required')
class SomeClass(models.Model):
  phone =  models.CharField(max_length=14, validators=[PHONE_REGEX])
Posted by: Guest on September-18-2020
0

django validators import

from django.core.validators import validate_slug, validate_email
from django.db import models

SlugField = models.CharField(validators=[validate_slug])
EmailField = models.CharField(validators=[validate_email])
Posted by: Guest on July-09-2021

Code answers related to "how to import validators in django"

Python Answers by Framework

Browse Popular Code Answers by Language