5
我有以下型號:在Django中,我有一個複雜的查詢,我只需要通過外鍵的唯一值,這可能嗎?
class Indicator(models.Model): name = models.CharField(max_length=200) category = models.ForeignKey(IndicatorCategory) weight = models.IntegerField() industry = models.ForeignKey(Industry) def __unicode__(self): return self.name class Meta: ordering = ('name',) class IndicatorRatingOption(models.Model): indicator = models.ForeignKey(Indicator) description = models.TextField() value = models.FloatField(null=True) def __unicode__(self): return self.description class Rating(models.Model): product = models.ForeignKey(Product, null=True) company = models.ForeignKey(Company, null=True) rating_option = models.ForeignKey(IndicatorRatingOption) value = models.IntegerField(null=True)
我需要做的就是讓所有的兩家公司的公司評級選項,而不需要對他們的指標(rating.rating_option.indicator)重疊。如果有衝突,公司'a'總會贏得公司'b'。我該怎麼做呢?