Nick Bewley
Nick Bewley

Reputation: 9289

Django: QuerySet object has no attribute

I get an AttributeError: 'QuerySet' object has no attribute 'ratings' when trying to do something like this in my view:

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

My model:

from ratings.models import Ratings

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

While using django-simple-ratings app. This link references where cumulative_score is defined in that module. How do I use cumulative score? Thank you for your ideas!

Upvotes: 0

Views: 4288

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599956

You've referenced ratings in your view, but defined the manager attribute as rating (no 's').

Upvotes: 2

Related Questions