📜  django m2m .add - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:39.196000             🧑  作者: Mango

代码示例1
p1 = Publication(title='The Python Journal')
p1.save()
a1 = Article(headline='Django lets you build Web apps easily')
a1.save()

a1.publications.add(p1)

# Adding a second time is OK, it will not duplicate the relation:
a1.publications.add(p1)