Created
          February 24, 2021 01:06 
        
      - 
      
- 
        Save NurElHuda/9e60a6bfa78e74ae5b6717dba3a6b4db to your computer and use it in GitHub Desktop. 
Revisions
- 
        NurElHuda created this gist Feb 24, 2021 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ from django.core.validators import RegexValidator from django.db import models from django.utils.crypto import get_random_string def get_random_phone(): return '07'+ get_random_string(length=8, allowed_chars='123456789') phone_pattern_validator = RegexValidator('(0|\+213|00213){1}([1-9]){1}([0-9]{8})', message='Invalid phone format') phone = models.CharField( max_length=16, unique=True, default=get_random_phone, blank=True, validators=[phone_pattern_validator,] )