我有2个型号:评论和产品:
class Review(models.Model):
user = models.ForeignKey(User, related_name="user_blog")
tag = TaggableManager()
product = models.ForeignKey(Product)
review_text = models.TextField()
created = models.DateTimeField(auto_now=True, auto_now_add=False)
updated = models.DateTimeField(auto_now=True, auto_now_add=True)
hashtag = models.ForeignKey(Hashtag)
class Product(models.Model):
name = models.CharField(max_length=500)
我想过滤与产品相关的所有标签,我这样做:
review = Review.objects.get(product=prod.id)
for tag in review.tag:
print tag.name
但我得到了:
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: '_TaggableManager' object is not iterable