Answers for "django m2m .add"

1

django m2m .add

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)
Posted by: Guest on July-16-2021

Python Answers by Framework

Browse Popular Code Answers by Language