django执行:

django.db.utils.IntegrityError: (1048,_用户信息

django.db.utils.IntegrityError: (1048, “Column ‘bpub_date’ cannot be null”)

直接对models中的用户信息进行修改,添加null=True后,如下图红色框所示:

django.db.utils.IntegrityError: (1048,_python_02

然后重新执行一俩操作:

python manage.py makemigrations
python manage.py migrate
python manage.py shell
E:\py-Django\django1day>python manage.py shell
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from booktest.models import BookInfo,HeroInfo
>>> BookInfo.objects.all()
<QuerySet []>
>>> b=BookInfo()
>>> b.btitle='射雕'
>>> from datetime import date
>>> b.bpub_date=date(1991,1,3)
>>> b.save()
>>> b=BookInfo()
>>> BookInfo.objects.all()
<QuerySet [<BookInfo: BookInfo object (1)>]>
>>> b=BookInfo.objects.get(id=1)
>>>> b
<BookInfo: BookInfo object (1)>
>>> b.btitle
'射雕'
>>> b.bpub_date
datetime.date(1991, 1, 3)
>>> b.bpub_date=date(2727,1,1)
>>> b.save()
>>> b.bpub_date
datetime.date(2727, 1, 1)

django.db.utils.IntegrityError: (1048,_数据库_03