About Setting Many-to-many Relationships
Use the set()
method of many-to-many relationship manager, to set the value to a list of objects. For example,
django_cookbook.authors.set([aidas, jake])
is equivalent to
django_cookbook.authors.clear()
django_cookbook.authors.add(aidas)
django_cookbook.authors.add(jake)
Tips and Tricks Programming Django 5.x Django 4.2 Django 3.2
Also by me
Django Paddle Subscriptions app
For Django-based SaaS projects.
Django App for You
Django GDPR Cookie Consent app
For Django websites that use cookies.
Django App for You