2

我练习Django 书第 10 章:高级模型并遇到问题

我将这些代码复制到我的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

模型.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

请帮我。谢谢

4

0 回答 0