我正在模型中使用django-phonenumber-field
。我想欧芹.js在客户端验证模型表单。但是,我找不到用于在服务器端验证PhoneNumberField
字段的正则表达式。在
如果可能的话,我真的很想用同样的表达方式。在
这是我的模型和表格:
from phonenumber_field.modelfields import PhoneNumberField
@python_2_unicode_compatible
class CVApplication(Application):
mobile_phone_number = PhoneNumberField()
[...]
@parsleyfy
class CVApplicationForm(forms.ModelForm):
class Meta:
model = CVApplication
fields = (
'mobile_phone_number',
[...]
)
def __init__(self, *args, **kwargs):
super(CVApplicationForm, self).__init__(*args, **kwargs)
self.fields['mobile_phone_number'].widget.attrs.update(
{'data-parsley-pattern': '??????????'}
)
[...]
谢谢你的帮助!在
django phonenumber字段依赖于python phoneumbers来验证电话号码。在
你可以从这里挑选出你需要的东西:https://github.com/daviddrysdale/python-phonenumbers/blob/dev/python/phonenumbers/phonenumbermatcher.py
相关问题 更多 >
编程相关推荐