0
我有兩個型號:Django查詢加入?
class Contact(models.Model):
name = models.CharField(max_length=255)
class Campaign(models.Model):
contact = models.ForeignKey(Contact, related_name="campaigns")
name = models.CharField(max_length=255)
如何選擇,在活動表競選有名字=「CAMPAIGNNAME」的所有聯繫人?
應該是'campaigns__name'對嗎?從related_name? –
是的,應該有related_name,所以campaigns_name是正確的。 – sunprophit