In my model, I have:
class Poll(models.Model): topic = models.CharField(max_length=200) tags = models.ManyToManyField(Tag)
I am trying to create a Poll object and store tags as follows:
Tags = [] for splitTag in splitTags: tag = Tag(name = splitTag.lower()) tag.save() Tags.append(tag)
How to set Tags array and assign it Tags ?
I tried:
poll = Poll(topic=topic, tags = Tags) poll.save()
source share