utils.py 文件源码

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

项目:montage 作者: storyful 项目源码 文件源码
def is_field_nullable(model_class, field_name):
    """ Helper function that checks if a field is nullable or not.
        It also handles the case of foreign key fields with the '_id' suffix
    """
    try:
        return model_class._meta.get_field(field_name).null
    except FieldDoesNotExist:
        # Make sure it's not foreign key
        if field_name.endswith('_id'):
            return model_class._meta.get_field(field_name[:-3]).null
        raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号