2013-01-08 171 views
0

试图做这样的事情在我看来,当我得到一个AttributeError: 'QuerySet' object has no attribute 'ratings'Django的:QuerySet对象有没有属性

def index(request): 
    thing_list = Thing.ratings.cumulative_score() 
    return render(request, 'index.html', {'thing_list':thing_list}) 

我的模型:当使用django-simple-ratings应用

from ratings.models import Ratings 

class Thing(models.Model): 
    user = models.ForeignKey(User) 
    ... 
    rating = Ratings() 

。这link参考其中cumulative_score在该模块中定义。我如何使用累积分数?感谢您的想法!

+0

发布完整的追踪(pastebin,...)? – DanielB

回答

2

您在视图中引用了ratings,但将管理器属性定义为rating(no's')。

+0

谢谢你的回答!不幸的是,如果你有任何进一步的想法,解决这个错误导致了另一个,我引用[这里](http://stackoverflow.com/questions/14227478/django-attributeerror-using-ratings-app)。感谢您的输入。 –

相关问题