0
我有一個模型,慈善與ManyToManyField關係運動,如下圖所示:Django的_set錯誤:「‘運動’對象有沒有屬性‘charity_set’」
class Charity(models.Model):
name = models.CharField(max_length=200)
description = models.TextField(blank=True,null=True)
tag_line = models.CharField(max_length=160, blank=True,null=True)
campaigns = models.ManyToManyField(Campaign, related_name='campaign_charity')
...
的ManyToManyField工作正常,和運動。 all()返回與慈善相關聯的正確的一組活動。當我嘗試使用object.charity_set我收到以下錯誤,以獲得反向設置對象:
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'Campaign' object has no attribute 'charity_set'
任何想法,爲什麼?謝謝!
+1尖端的所有屬性/方法。 – Paragon