2

I practice The Django Book Chapter 10: Advanced Models and have problem

I copy these code below in my model.py,and then run python manage.py sqlall books in termial as the website said,but there are errors.

Is it because my database is 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

Please help me. Thank you

user2492364
  • 6,543
  • 22
  • 77
  • 147
  • I think because mongodb is not SQL and Django has no officially support for it, that command doesn't work. If you are learning, try the most simple posible setup with sqlite. – elmonkeylp Sep 16 '14 at 02:10
  • I am supposed to use mongodb as a part of the project. What can be the possible answer to this error?Here is the link for my question, http://stackoverflow.com/questions/42202928/error-while-syncdb-django-mongo – Shachi Feb 14 '17 at 07:20

0 Answers0