field.py 文件源码

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

项目:django-localized-fields 作者: SectorLabs 项目源码 文件源码
def validate(self, value: LocalizedValue, *_):
        """Validates that the values has been filled in for all required
        languages

        Exceptions are raises in order to notify the user
        of invalid values.

        Arguments:
            value:
                The value to validate.
        """

        if self.null:
            return

        for lang in self.required:
            lang_val = getattr(value, settings.LANGUAGE_CODE)

            if lang_val is None:
                raise IntegrityError('null value in column "%s.%s" violates '
                                     'not-null constraint' % (self.name, lang))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号