4
在我的模型,我有:Django的ManyToManyField
class Poll(models.Model):
topic = models.CharField(max_length=200)
tags = models.ManyToManyField(Tag)
我試圖創建民意調查對象和存儲標籤,像這樣:
Tags = []
for splitTag in splitTags:
tag = Tag(name = splitTag.lower())
tag.save()
Tags.append(tag)
如何設置Tags
陣列並將其分配到tags
?
我曾嘗試:
poll = Poll(topic=topic, tags = Tags)
poll.save()