I have a DateTimeField in one of my Django models.
completed_date = models.DateTimeField('date completed', blank=True, null=True)
I've defined it to allow blank and null values. However, when I try to create an instance of the mod开发者_JS百科el, I get the following error:
IntegrityError at /admin/tasks/project/add/
tasks_project.completed_date may not be NULL
I'm using Django 1.25 and Python 2.7. Anyone know why this is happening? Is there anything I can do to fix this?
I found a ticket that describes the same problem, but it was closed as fixed 4 years ago, so I assume it must have been integrated into Django by now!
django syncdb and an updated model
from that question/answer:
Django doesn't support migrations out of the box. There is a pluggable app for Django that does exactly that though, and it works great. It's called South.
http://south.aeracode.org/
Havent used django in a while, but i seem to remember that syncdb does perform alter commands on db tables. you have to drop the table then run again and it will create again.
精彩评论