首页 > 解决方案 > 我的 Django models.py 文件中有一个验证错误

问题描述

我正在使用 models.py 文件在 Django 中创建一个表,当我运行代码时,它会给出一个验证错误,如下所示:


        django.core.exceptions.ValidationError: ['“null” value must be either True or False.']

这是我的 models.py 文件

from django.db import models


class Users:
    id = models.IntegerField(primary_key=True)
    first_name = models.CharField(max_length=250)
    last_name = models.CharField(max_length=250)
    username = models.CharField(max_length=50)
    password = models.CharField(max_length=300)
    birthday = models.DateField(auto_now_add=False)
    date_created = models.DateTimeField(auto_now_add=True)
    terms_confirmed = models.BooleanField(default=False)

我已经尝试用布尔值注释掉字段,并挑选出每一行以查看它是否会产生错误

标签: pythondjango

解决方案


推荐阅读