社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

Chris Curvey

Chris Curvey 最近创建的主题
Chris Curvey 最近回复了
7 年前
回复了 Chris Curvey 创建的主题 » python-返回前验证电话号码

也许只需要在 初始化 在那里决定你是否有一个有效的号码?

class FormattedPhoneNumber(object):
  def __init__(self, number):
    try:
      as_number = int(number)
    except (TypeError, ValueError):
      self._formatted = None
    else:
      # you have a number, do whatever formatting you need to do
      area_code = number[ 0:3 ]
      exchange = number[ 3:6 ]
      line = number[ 6:13 ]
      self._formatted = "({0}) {1}-{2}".format(area_code,exchange,line)

  def __str__(self):
    return self._formatted
7 年前
回复了 Chris Curvey 创建的主题 » Django 2不同模型字段项

变化

context['colors']=Student.objects.all(
       ).order_by('color').distinct('color')

context['colors']=self.student_set.all(
       ).order_by('color').distinct('color')