私のmodel.pyファイルは
from django.db import models
class Book(models.Model):
book_id=models.AutoField(primary_key=True,unique=True)
book_name=models.CharField(max_length=30)
author_name=models.CharField(max_length=30)
publisher_name=models.CharField(max_length=40)
def __unicode__(self):
return "%d %s %s %s" % (self.book_id,self.book_name, self.author_name,self.publisher_name)
class Author(models.Model):
author_id=models.AutoField(primary_key=True)
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=40)
email = models.EmailField()
book=models.ForeignKey(Book)
def __unicode__(self):
return u'%d %s %s' % (self.author_id,self.first_name, self.last_name)
「class Book」の場合、 を使用して MySQL にテーブルを作成しましmanage.py syncdb
た。しかし、「Author」という名前の新しいテーブルでデータベースを更新する方法があります。同じことを行うための手順が必要です。私は後者を同じようにしようとしていますが、DBにテーブルが作成されていないためです。