模型 图书和作者是多对多关系
class Book(models.Model):
book_name=models.CharField(max_length=40)
price=models.DecimalField(max_digits=4,decimal_places=2)
publish=models.ForeignKey(to="Publish",on_delete=models.CASCADE,related_name="publish")
author=models.ManyToManyField(to="Author",related_name="author")
class Meta:
db_table="tbl_book"
# def __str__(self):
# return self.book_name
class Publish(models.Model):
publish_name=models.CharField(max_length=20)
address=models.CharField(max_length=30)
class Meta:
db_table="tbl_publish"
# def __str__(self):
# return self.publish_name
class Author(models.Model):
sex_choices=[(0,"男"),(1,"女")]
name=models.CharField(max