forms.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:balafon 作者: ljean 项目源码 文件源码
def clean(self, value):
        """
        Validates that the input is in self.choices.
        """
        value = super(GroupedChoiceField, self).clean(value)
        if value in (None, ''):
            value = u''
        value = forms.util.smart_unicode(value)
        if value == u'':
            return value
        valid_values = []
        for choice in self.choices:
            group = choice[1]
            valid_values += [str(key) for key, value in group]
        if value not in valid_values:
            raise ValidationError(_(u'Select a valid choice. That choice is not one of the available choices.'))
        return value
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号