我练习The Django Book Chapter 10: Advanced Models并遇到问题
我将这些代码复制到我的model.py中,然后在网站上运行python manage.py sqlall books
,但有错误。
是因为我的数据库是django-mongodb-engine?
/Users/wi/ENV/lib/python2.7/site-packages/django_mongodb_engine/creation.py:98:
DeprecationWarning: 'descending_indexes', 'sparse_indexes' and 'index_together' are
deprecated and will be ignored as of version 0.6. Use 'indexes' instead.
"Use 'indexes' instead.", DeprecationWarning)
Installing indices for books.Publisher model.
TypeError: 'NoneType' object is not iterable
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()
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()
def __unicode__(self):
return self.title
请帮帮我。谢谢