0
的領域我有這樣的模式:比較同型號
#Model for match result forecast
class ResultForecast(models.Model):
user = models.ForeignKey(User)
created_date = models.DateTimeField('match date', blank=True, null=True)
home_goals = models.DecimalField(max_digits=5, decimal_places=0, blank=True, null=True)
away_goals = models.DecimalField(max_digits=5, decimal_places=0, blank=True, null=True)
match = models.ForeignKey(Match, related_name='forecasted_match')
所以我想要得到的地方去home_goals比客場進球,反之亦然更大的物體,我用這個:
total_forecast = ResultForecast.objects.filter(match=match).count()
home_trend = ResultForecast.objects.filter(match=match, home_goals__gt=F('away_goals'))
away_trend = ResultForecast.objects.filter(match=match, away_goals__gt=F('home_goals'))
但它不起作用