【发布时间】:2018-06-05 00:05:48
【问题描述】:
我已经看到了许多电话示例以及用于手机号码字段的第三方包。但我想要的是这个:
+country_code 或空格(这3个是可选的)phone_number(最小范围号码= 8,最大为13) 例如:+65、98654578
基于其中一个示例,它可以工作,但不是我想要的。 :What's the best way to store Phone number in Django models
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
我做的是这个:
mobile_regex = RegexValidator(regex=r'^\+?1?\d{1-3}?\,?\s?\d{8-15}$', message="Phone number must not consist of space and requires country code. eg : +6591258565")
但它不起作用。我做错什么了吗?请帮帮我
【问题讨论】: