私はDjangoを学んでおり、「The Django Book」でモデルの章を完成させましたが、以下の質問のためにManyToManyとForeignKeyに値を挿入する方法がわかりませんでした:
"Author"
この下のモデルでは、詳細を挿入するにはどうすればよいです"Publisher"
かbook name = "The book"
publication-date = "28/10/2013"
値を挿入した後、どうすれば元に戻すことができ"Author"
ます"Publisher"
かbook name = "The book"
class Author(models.Model):
first_name = models.CharField(max_length = 20)
last_name = models.CharField(max_length = 20, blank = True)
email = models.EmailField(blank = True)
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()
class Book(models.Model):
title = models.CharField(max_length=100)
publisher = models.ForeignKey(Publisher)
authors = models.ManyToManyField(Author)
publication_date = models.DateField()