开发者

django-ratings problem

I have just installed the django-ratings app and I am having some trouble getting it working. I have successfully added a rating field to my model, however, in the documentation, it says you can get a list of records by rating by using the following code:

    # In this example, ``rating`` is the attribute name for your ``RatingField``
    qs = qs.extra(select={
        'rating': '((100/%s*rating_score/(rating_votes+%s))+100)/2' % (MyModel.rating.range, MyModel.rating.weight)
    })
    qs = qs.order_by('-rating')

I have added the following to my class based generic view:

def get_queryset(self):
        return Resource.objects.filter(user=self.request.user).extra(select={
        'rating': '((100/%s*rating_score/(rating_votes+%s))+100)/2' % (Resource.rating.range, Resource.rating.weight)
    })

However, this gives me the following e开发者_StackOverflow中文版rror:

'RatingField' object has no attribute 'range'

Can anyone see what I might have done wrong?

Any advice appreciated.

Thanks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜