1. # 一对一增加
    2. # create_obj = models.authorDetail.objects.create(
    3. # birthday = '2001-01-01',
    4. # telephone='010200',
    5. # addr='山西临汾',
    6. # )
    7. # 方式一
    8. # models.author.objects.create(
    9. # name='张三',
    10. # age = '18',
    11. # authorDetail=create_obj,
    12. # )
    13. # obj = models.authorDetail.objects.filter(addr="山西临汾").first()
    14. # # 方式二 没成功
    15. # models.author.objects.create(
    16. # name='李四',
    17. # age = '19',
    18. # authorDetail_id=obj.id,
    19. # )
    20. # 一对多
    21. # 方式1
    22. # obj = models.Publish.objects.get(id=1)
    23. # models.Books.objects.create(
    24. # title='Linux从入门到精通',
    25. # publisdate='2021-10-01',
    26. # price='99.99',
    27. # publishs=obj,
    28. # )
    29. # obj = models.Publish.objects.get(id=1)
    30. # models.Books.objects.create(
    31. # title='Django入门到精通',
    32. # publisdate='2021-10-01',
    33. # price='99.99',
    34. # publishs_id=obj.id,
    35. # )
    36. # 多对多
    37. # book_obj = models.Books.objects.get(bid=1)
    38. # book_obj.authors.add(*[1,2])