Я создал поле ManyToManyField
class Picture(models.Model):
link = models.CharField('picture_link', max_length=200)
def __str__(self):
return self.link
class MyModel(models.Model):
picture = models.ManyToManyField(Picture, blank=True)
И пытаюсь добавить модель в поле
for pic in arr:
_picture = pic.text
try :
picture = Picture.objects.get(link = _picture)
except:
picture = Picture(link = _picture)
picture.save()
mymodel.picture.add(picture)
Но получаю ошибку
Cannot add "<Picture: https://nndd.com/wa-data/public/shop/products/29/13/1329/images/538/538.602x0.jpg>": instance is on database "None", value is on database "default"