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'))
但它不起作用