如何在一个查询中计算一组答案得分?

问题描述

| 我正在编写类似于Stackoverflow的webapp。我如何查询问题并用分数来注释每个问题,分数就是它拥有多少赞成票减去其拥有多少赞成票。
class Question(models.Model):
    pass

class Answer(models.Model):
    pass

VOTE_CHOICES = (
    (\'U\',\'Up\'),(\'D\',\'Down\'),)

class Vote(models.Model):
    user = models.ForeignKey(User)
    answer = models.ForeignKey(Answer)
    type = models.CharField(max_length=1,choices=VOTE_CHOICES,db_index=True) 

    class Meta:
        unique_together = ((\"user\",\"answer\"),)
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)