>>> i = ProductImage.objects.get(pk=100)
>>> p.images.set([100])
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.8/dist-packages/django/db/models/fields/related_descriptors.py", line 750, in set
self.add(*objs, bulk=bulk)
File "/usr/local/lib/python3.8/dist-packages/django/db/models/fields/related_descriptors.py", line 656, in add
check_and_update_obj(obj)
File "/usr/local/lib/python3.8/dist-packages/django/db/models/fields/related_descriptors.py", line 648, in check_and_update_obj
raise TypeError("'%s' instance expected, got %r" % (
TypeError: 'ProductImage' instance expected, got 100
However, this works fine:
p.images.set([i])