将电话号码插入Djang型号

2024-04-26 15:07:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我是Python/Django的新手,我试图在模型的字段中插入电话号码。在

我在我的模型.py是

from django.db import models
from django.core.validators import * 

telephone = RegexValidator(r'^\d+$', 'Only numeric characters are allowed.')

class Registration(models.Model):
      mobile_telephone = models.PositiveIntegerField(max_length=18, validators=[telephone, MaxLengthValidator])

代码表单.py在

^{pr2}$

我试过了模型.py对于IntegerField、CharField和PositiveIntegerField,但是它们都不允许在字段的开头使用0。在

我做错什么了?在

谢谢


Tags: djangofrompycore模型importdbmodels