在模型中:
class Match(models.Model):
user = models.ManyToManyField(User, blank=True)
hot_league = models.ManyToManyField('HotLeague', blank=True)
class HotLeague(models.Model):
user = models.ManyToManyField(User, blank=True)
price_pool = models.IntegerField()
winner = models.IntegerField()
在视图中:
match = Match.objects.filter(user=request.user)
hot_league = match.hot_league.filter(user=request.user).count()
这里是风景区
count()
不起作用。
我怎么能数到
hot_league
位于
match
??