Did you perhaps change the schema of the database after you had created it.
Eg: added null=True as a constraint after creating the table?
python manage.py sqlall <appname>
python manage.py dbshell
On Wed, Mar 26, 2014 at 3:31 PM, Sami Razi <s.sami.ghayeni@gmail.com> wrote:
--
i'm learning django using djangobook, in chapter 6, i'm having this error:
IntegrityError at /admin/books/book/add/
NOT NULL constraint failed: books_book.publication_date
it seems i should set null=True for publication_date field. but i did it already, this is my models.py:
from django.db import models
class Publisher(models.Model):
name = models.CharField(max_length=30)
address = models.CharField(max_length=50)
city = models.CharField(max_length=60)
state_province = models.CharField(max_length=30)
country = models.CharField(max_length=50)
website = models.URLField()
def __unicode__(self):
return self.name
class Author(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=40)
email = models.EmailField(blank=True, verbose_name='e-mail')
def __unicode__(self):
return u'%s %s' % (self.first_name, self.last_name)
class Book(models.Model):
title = models.CharField(max_length=100)
authors = models.ManyToManyField(Author)
publisher = models.ForeignKey(Publisher)
publication_date = models.DateField(blank=True, null=True)
def __unicode__(self):
return self.title
what am i doing wrong?
i googled the error message but didn't find a related answer.
thank you for your help.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/87ef0e56-f90f-4097-8a2c-e747ac874b71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMbLS2-4SLs_OqCrKj4qQm_Xif2oDsCG97RJWDmrAFUR%2BCuxNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment